Skip to content

test-coverage: src/bits/popcount.rs flaps ±26pp on x86 because the AVX-512 VPOPCNTDQ path is CPU-conditional on the runner #302

Description

@newhoggy

Category: test-coverage / SIMD dispatch — surfaced by the coverage comment on PR #287 (a one-line dorny/paths-filter dependabot bump that changes no Rust code).

Problem

src/bits/popcount.rs swings ±26pp on the x86_64 coverage leg between otherwise-unrelated PRs, because its AVX-512 VPOPCNTDQ path is only executed on runners whose CPU actually has the instruction. The x86 SIMD gate (.github/workflows/ci.yml:76) pins SUCCINCTLY_EXPECT_SIMD: sse2,sse4.2,avx2,bmi2,popcntavx512vpopcntdq is deliberately not required (GitHub-hosted ubuntu-latest doesn't guarantee it). So on the coverage job (also ubuntu-latest), the AVX-512 region is present-but-uncalled on some hosts and executed on others.

The CPU-gated lines, all compiled under --features cli,simd,regex,serde but only reachable with avx512vpopcntdq:

  • popcount_words_avx512vpopcntdq body — popcount.rs:218-245 (loop, _mm512_loadu_si512, _mm512_popcnt_epi64, _mm512_reduce_add_epi64, scalar tail).
  • The runtime-dispatch arm in popcount_words_x86popcount.rs:261-266 (if is_x86_feature_detected!("avx512vpopcntdq") { return unsafe { … } }).
  • Both host-gated tests, which early-return on non-supporting CPUs and so neither cover nor validate the kernel there:

That's ~30 executable lines counted in the file's denominator but coverable only on AVX-512-VPOPCNTDQ hardware.

Evidence

PR #287's coverage-x86_64 comment flagged src/bits/popcount.rs 92.86% → 66.43% (🔴 -26.43pp) under "1 unchanged file(s) also moved (not attributed to this PR)". The diff is a single line in ci.yml — the swing is purely that the main baseline run and the PR-head run drew different runner CPUs (one with the VPOPCNTDQ instruction, one without).

Why this isn't already covered / caught

Unlike the SSE2 (#247) and DSV-dispatch (#283) cases, this path cannot be forced on a CPU that lacks the instruction: _mm512_popcnt_epi64 will SIGILL there, and a software shim would no longer be testing the intrinsic. So the AVX-512 kernel's correctness is inherently only verifiable on AVX-512 hardware, and its coverage is inherently non-deterministic across GitHub's runner fleet.

Practical severity: low (cosmetic)

  • The coverage bot already quarantines this into "unchanged files … not attributed to this PR" and does not count it as a patch-coverage regression.
  • The fail-under-lines: 55 gate (ci.yml:523) has ~19pp of headroom over the ~74.5% total, so a one-file -26pp wobble won't trip it.

So this is recurring visual noise in the sticky comment, not a gate or correctness problem. Filing it so the noise is understood and (optionally) silenced deterministically, rather than re-diagnosed on every unrelated PR.

Options (pick one)

  1. Exclude the hardware-gated region from coverage measurement so popcount.rs reports a stable number regardless of runner CPU. Depends on what action-works/omni-dev-coverage-check / cargo-llvm-cov expose — nightly #[coverage(off)] on popcount_words_avx512vpopcntdq + the dispatch arm + the two host-gated tests, or --ignore-filename-regex for the whole file, or an omni-dev ignore-list config. (Preferred if a region-level mechanism exists; whole-file exclusion is the blunt fallback.)
  2. Teach omni-dev coverage diff to suppress a configured allowlist of known-CPU-conditional files (src/bits/popcount.rs, and arguably the src/dsv/simd/* and src/yaml/simd/* dispatchers) from the "unchanged files also moved" section, so they never surface as noise on unrelated PRs. (Upstream change in the action/omni-dev, not this repo.)
  3. Pin the coverage runner to a CPU class that has AVX-512 VPOPCNTDQ (deterministic-up), or add avx512vpopcntdq to a dedicated expect-simd leg. Fragile — GitHub-hosted runner CPUs aren't contractually stable — and it would then require the feature, which contradicts the current intentional non-requirement.
  4. Accept the noise, document it. Add a short note (CONTRIBUTING.md "SIMD CI coverage" section, near the existing expect-simd guidance) explaining that popcount.rs flaps by design, so it isn't re-triaged each time. Cheapest; no determinism gain.

Definition of done

  • src/bits/popcount.rs's x86 coverage number is deterministic across runner CPUs or the flap is explicitly documented so it's not re-investigated per PR.
  • No change to production popcount dispatch or the intentional non-requirement of avx512vpopcntdq.
  • If code/config is touched: clippy --all-targets --all-features -D warnings clean; conventional commit with the appropriate scope.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ciCI/CD and GitHub ActionsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions