Skip to content

casei: close the Rebar Unicode gaps - #12

Merged
tsenart merged 5 commits into
masterfrom
publish/close-casei-gaps
Aug 25, 2026
Merged

casei: close the Rebar Unicode gaps#12
tsenart merged 5 commits into
masterfrom
publish/close-casei-gaps

Conversation

@tsenart

@tsenart tsenart commented Aug 24, 2026

Copy link
Copy Markdown
Owner

The original arena covered first-match search and single-needle counting. Rebar then exposed the missing question: enumerate non-overlapping Unicode-simple-fold matches. casei won two of the five rows with the same contract and lost three, with the worst row roughly nine times slower.

This change closes that gap while preserving the existing contract and one-engine design.

Before and after

before
  single Unicode survivor -> decoded confirmation -> Each decodes width again
  multi Unicode survivor  -> exact-check every pattern tag
  long multi scan          -> begin the tagged scan at byte 0

after
  single Unicode survivor -> bounded raw-form confirmation -> exact source width
  multi Unicode survivor  -> vector returns surviving tags -> check those tags
  long multi scan          -> exact shared byte -> bounded start -> same tagged plan

match authority in both versions
  one compiled fold-token plan -> leftmost start -> lowest pattern ID -> exact width

The three added mechanisms each have a measured consumer. Removing variable confirmation loses two of five same-contract Rebar rows on both hosts. Ignoring returned tags loses one on Ice Lake. Removing the common-byte origin gate loses the focused N=5 arena rows on both hosts.

The amd64 work also widens the exact-byte and tagged VBMI schedules so independent cache lines remain in flight before ordered mask tests. OpcodeX supports the Ice Lake scheduling explanation. Sapphire Rapids is supported by emitted disassembly, direct execution, and full-field measurements because the current OpcodeX catalog has no Sapphire Rapids column.

Result

  • Ice Lake: 36/36 BenchmarkBar rows, worst median x_vs_best=0.9614, worst sample 0.9622.
  • Sapphire Rapids: 36/36 rows, worst median 0.9693, worst sample 0.9716.
  • Every arena row has 5 to 7 entrants. casei reports 512-bit dispatch and Vectorscan reports a 512-bit VBMI database.
  • Rebar same-contract rows: 5/5 wins on both hosts, worst 0.8766 on Ice Lake and 0.8919 on Sapphire Rapids.
  • All 18 representable Rebar rows remain published. Thirteen request ASCII-only matching and are labeled stress data because casei preserves Unicode simple folding.

Evidence

The checked-in record contains:

  • three full paired BenchmarkBar passes per host;
  • three Rebar passes per host;
  • full native-field agreement and dispatch checks;
  • differential tests, portable-path tests, race, checkptr, amd64 and arm64 builds, and both fuzz targets;
  • source-pinned GDB receipts for the three changed native entries on both CPUs;
  • per-mechanism two-host ablations;
  • SHA-256 manifests and executable summarizers.

Local gates pass: go test, race, vet, staticcheck, golangci-lint, gofmt, cross-builds, baseline isolation, receipt verification, and git diff --check.

The persistent Bentley/Thompson panel is green after one accepted evidence finding. The repair scoped the historical 36-entry GDB claim to its old commit and added current two-host reachability receipts. Distill removed mechanisms without measured consumers; the thermo review removed four dead helpers/accessors.

Scope

The speed claim covers x86-64 AVX-512F/BW/VBMI on Ice Lake and Sapphire Rapids. The portable and ARM64 paths remain correct and scalar. Full-fold expansion and general regex syntax remain outside the API.

The pushed commit is f109e85. Its tree is 76d988f95380e236a78dc9fe76207302bb72aca3, identical to the clean tree already exercised on both VMs. The PR remains draft while the extra immutable-tree hardware rerun is completed.

perfloop-agent and others added 5 commits August 24, 2026 14:25
The original arena omitted multi-pattern enumeration and the hard Unicode shapes that exposed decoded confirmation cost. Rebar found three same-contract losses, including a roughly ninefold gap.

Add tagged multi-pattern candidates, width-aware raw confirmation, an exact common-byte origin gate, and wider AVX-512 schedules. Pair each field timing with its competitor and retain the two-host field, Rebar, ablation, and native-reachability receipts.

The resulting source wins every current arena row and all five same-contract Rebar rows on Ice Lake and Sapphire Rapids while preserving the simple-fold contract and portable fallback.
The library supports Go 1.22, while testing.B.Loop was added in Go 1.24. Keep the diagnostic benchmark and its B.Loop timing semantics without making the ordinary amd64 test file require a newer toolchain.
Go vet checks assembly stack operands against the declaration names. Name the two multi-value results so the existing ret, width, and tags operands match the Go ABI without changing the generated instruction stream.
@tsenart
tsenart merged commit ec68359 into master Aug 25, 2026
4 of 8 checks passed
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