Skip to content

perf(research): compile the P112 ten-deletion census with popcnt (2.69x, byte-identical receipts) - #4090

Open
kumagi wants to merge 1 commit into
CrocSwap:mainfrom
kumagi:research/p112-ten-deletion-mpopcnt
Open

kumagi wants to merge 1 commit into
CrocSwap:mainfrom
kumagi:research/p112-ten-deletion-mpopcnt

Conversation

@kumagi

@kumagi kumagi commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

One-line verifier change: compile research/p112-ten-deletion-span/census.cpp with -mpopcnt.

The shipped -O3 build compiles for baseline x86-64 without a POPCNT target feature, so every count(Mask) lowers to an opaque out-of-line call to libc __popcountdi2. Callgrind on a 5-rep budget-8 run attributes 25.04% of all retired instructions to that call, and hiding it inside a function boundary also blocks loop vectorization around the census / deletable hot loops. The sibling packages research/p112-common-deletion-slice and research/p112-common-fourteen-cut (same PR3161 descent) already compile with -mpopcnt; this successor dropped it.

Measured result

Same host (32-core Linux, gcc 15), same fixture, same interpreter, back-to-back builds differing only in the flag:

invocation before after speedup
census FIXTURE 8 39.10 s 15.00 s 2.61x
census FIXTURE 10 99.69 s 43.67 s 2.28x
full registered replay (verify.py --work) 155.94 s 57.91 s 2.69x
  • Both census stdout streams are byte-identical before/after (cmp of the retained diagnostics), and the registered replay passes unchanged (PASS_P112_TEN_DELETION_SPAN span=4 beta_5_4_remaining=2, receipt compared to RESULT.json inside verify.py, no --output).
  • scripts/research_package.py --check-only PASS; registered command 2 (test_verify.py, -O -Werror) PASS.
  • mpopcnt is available on the committed replay hardware (the dedicated workflow runs only ubuntu-latest GH runners); outputs are unaffected because popcount semantics are target-independent.

Scope

  • research/p112-ten-deletion-span/verify.py only (+1 line in FLAGS). No census source change, no mathematical claim, no receipt, no other package.

Cross-references the measured handoff in #1166.

Callgrind on the shipped -O3 binary shows 25.0% of all retired
instructions inside libc __popcountdi2 calls: without a popcnt target
feature every count(Mask) is an opaque out-of-line call, which also
blocks loop vectorization around the census and deletable hot loops.
The sibling packages research/p112-common-deletion-slice and
research/p112-common-fourteen-cut already compile with -mpopcnt.

Measured on the same host, same fixture, byte-identical stdout for both
registered censuses and identical RESULT.json: full registered replay
155.94 s -> 57.91 s (census 8: 39.10 -> 15.00 s, census 10:
99.69 -> 43.67 s). No mathematical or output change.
@rcfc-jreed

Copy link
Copy Markdown
Contributor

Independent scoped check of #4090 P112 ten-deletion popcnt compile flag at 1c405757: flag present (2/2)

Scoped perf change only (-mpopcnt added to C++ FLAGS). CLAIM.

What passes:

  1. Diff is exactly one FLAGS entry: "-mpopcnt" inserted before "-O3".
  2. No other verify.py logic changes in the PR patch.

Not covered: re-timing the 2.69× claim on this machine; full package rebuild/receipt replay (out of this one-line scope). Byte-identical receipts were not re-run here.

James Reed (@rcfc-jreed), with substantial AI assistance (Claude, in Cursor).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants