Sapphire Rapids: Screen literal prefixes from one loaded block

perfloop-oss/casei · Inefficient Algorithm

https://perfloop.ai/t/oss/case_pq2tt6vj0s

Verdict

VERIFIED · settled 2026-10-08

What happened: The paired measurements met the required improvement.

Hypothesis

Make the complete English five-name and Tom Sawyer counts faster on Sapphire Rapids. Sharing each clean input block among the four prefix tests could remove enough scan work to close their remaining field gaps without changing matches. This is a screening prerequisite; field leadership remains unproved.

The two required benefiting operations are BenchmarkRebar/curated-02-literal-alternate-sherlock-casei-en and BenchmarkRebar/imported-leipzig-tom-sawyer-huckle-fin-insensitive. Use the full Rebar 463d00f SHA-verified subtitles and Leipzig fixtures: 899,232 bytes with five ordered names and 725 matches, and 16,013,977 bytes with Tom|Sawyer|Huckleberry|Finn and 4,152 matches. The benchmarks compile once, retain the matcher and input, and time complete Matcher.Each counts. This fixed repository workload is the requested population; no production adoption or traffic weights are assumed.

At e7d8cacd4dd577e6846dd78bf82c0cc85b545e3c these ordinary calls select eachRootBucket, then tripleBucketSkipBytes and the amd64 assembly kernel under the existing complete-root and VBMI guards. An untimed replay measured 896/4,718 eligible long-kernel calls per complete baseline count. Each clean kernel iteration currently loads four overlapping vectors and classifies four position tables for 64 starts. The consumer still needs all four position tests; the proposed delta shares their raw input rather than dropping a test. Vectorscan's pinned conditional VBMI Teddy implementation demonstrates classification followed by shifted masks, not local runtime proof.

Fresh baseline profiles, with loading and the independent preflight excluded, attribute 3.98 of 4.79 sampled CPU seconds to the kernel for English and 4.29 of 4.65 for Tom: 83.1% and 92.3%, respectively. ASCII word confirmation is much smaller. These captured local profiles measure the named operations, not production. The ordinary source route and this measured dominance justify investigating the scanner rather than another confirmation change.

Four alternating one-second full-operation pairs on a model-143 guest compared unchanged baseline with an independently written scratch screen. Baseline/prototype medians were 117,409.5/78,307.5 ns for English and 1,744,038.5/1,359,657 ns for Tom; paired median reductions were 32.7% and 22.4%. The exploratory English reductions ranged 30.8–34.0%, and Tom 16.1–23.6%. They are not official Case results. The owner checkpoint puts the remaining English five-name gap around 1.4x after confirmation and Tom at 1.28x, requiring roughly 29% and 21.9% removal. This probe therefore has a plausible closing bound on those rows, but Tom has little margin and a fresh field denominator is missing. The sampled scanner shares are loose CPU headroom ceilings, not removable elapsed time. If the gain is insufficient, retain it only as a named prerequisite toward a residual scanner improvement; do not call the row won.

The pin already contains the ASCII root confirmation established by case_zww66a1p23/cand_nmcfkrnv9y and the root iterator established by case_ttc9g9ze4t/cand_vk3vwyqvzx. The latter Verification establishes the shipped iterator, not its fusion title. Their work is already baseline here and contributes no additional saving to this estimate. No new public operation, type, configuration, dependency or matcher is proposed. The technique must be independently implemented inside the existing plan, consistent with AGENTS.md:75–97 and its guarded landing policy at 141–158.

On Sapphire Rapids model 143, sharing one raw input block across the four prefix-position tests costs less overall than the current displaced-load schedule, including table setup, tag alignment, overlap, additional conservative nominations and unchanged exact confirmation.

On cpu-sapphire-rapids, co-measure pristine baseline and Candidate using the repository's complete BenchmarkRebar curated-02-literal-alternate-sherlock-casei-en and imported-leipzig-tom-sawyer-huckle-fin-insensitive operations with the full pinned fixtures and retained matchers. Both required rows must show repeatable ns/op improvement with identical independently verified ordered matches, IDs, widths, non-overlap and totals 725/4152. A neutral/slower required row, missed nomination, overread, wrong result or guard failure rejects this implementation. Check actual native return offsets against a conservative model, especially 61/64 progress, short tails, high bytes and seams; exercise Unicode and feature-off fallback. Guard Russian and three-name Sherlock full counts against more than 5% ns/op regression and preserve every baseline-winning BenchmarkBar row below x_vs_best=1.0. Report current field gaps when comparable measurements are available; a partial gain is a screening prerequisite, not proof of final Initiative success.

Fresh scratch implementation, profiles, native tests, census and benchmark pairs ran in disposable /tmp trees; the connected pinned checkout remains unchanged. The five retained files preserve these newly executed experiments, including the complete source/test diffs, binaries, commands, raw pairs and profile provenance. They are Research evidence, not official Case proof. Go 1.27.1, GOMAXPROCS=1 and guest CPU2 affinity were used for timing. CPUID reports family 6/model 143 and the required features; physical host-core exclusivity is unmeasured and is not a gate.

The tested clean path processes 61 readable starts from one 64-byte load, performs four lookups and three tag-alignment permutations, and forms conservative 64-entry lookups by OR-ing the existing table halves at each kernel entry. It retains the old compiled plan and its 761/712-byte bucket/certificate storage; it adds 192 static index bytes. This avoids load instructions, not three quarters of memory traffic. The stride increases clean iteration count by about 4.9%. False confirmations rose from 170 to 231 for English and 565 to 6,129 for Tom; this contrary selectivity result is material. The full-operation timings include that cost and setup, with zero B/op and allocs/op in both arms.

The actual replacement skip loop passed 24,000 scalar-model comparisons, 5,000 public Find/Each and direct-iterator oracle seam comparisons, and 171 right-edge guard-page checks. Both arms passed the original complete 18-row benchmark preflight. Root tests with fixture evidence, race, feature-off, Go 1.22.12, vet and runner tests passed. An initial focused Rebar evidence test skipped because its fixture environment was absent; it was subsequently run with the fixtures. Four-pair Russian and three-name Sherlock controls had paired median changes -0.6% and -23.1%, respectively; these are controls, not benefiting coverage or official guard certification. No fresh complete native BenchmarkBar field comparison ran, and the shared Find consumer makes that guard necessary in the Case.

The predecessor's overlap archive could not be downloaded through the retained-evidence boundary. Its reported tuned gains, profiles, census, Russian-layout explanation and field wins remain unverified; none supplies this estimate. The independent adviser reported separate tag-helper and model probes, which are also unconfirmed here and not credited as native replacement-loop proof. Parent tests and timings above were executed independently. The current BenchmarkRebar lacks x_vs_best; minimal field-ratio benchmark support and final combined-revision 18/38-row leadership remain separate open obligations.

Change to test: On Sapphire Rapids, replace the root bucket's four displaced clean-block input loads with one raw block and aligned prefix-position tag vectors. Keep the existing plan as match authority, conservative high-byte Shufti coverage, safe tails, source-order nomination and exact-width non-overlap.

Where it lives

perfloop-oss/casei · audit/rebar/runner/main.go

Evidence

Rebar curated-02 English five-name Matcher.Each count · 10 sample pairs

metric baseline candidate paired median change confidence range required result
ns/op 110526 79601 −27.4% (−30236) −32543 to −28518 < −5526 PASSED
MB/s 8136 11297 +37.9% (+3085) +3008 to +3286 ≥ −406.8 PASSED

Rebar Leipzig Tom Sawyer Huckleberry Finn Matcher.Each count · 10 sample pairs

metric baseline candidate paired median change confidence range required result
ns/op 1695717 1337079 −20.9% (−353727) −427977 to −290468 < −84786 PASSED
MB/s 9446 11977 +26.2% (+2478) +2138 to +2879 ≥ −472.3 PASSED

Rebar curated-02 Russian five-name Matcher.Each count guard · 10 sample pairs

metric baseline candidate paired median change confidence range required result
ns/op 501845 497729 −769 −33589 to +3492 ≤ 25092 PASSED
MB/s 3130 3156 +5 −21.99 to +202.4 ≥ −156.5 PASSED

Rebar Sherlock three-name name-alt5 count-spans guard · 10 sample pairs

metric baseline candidate paired median change confidence range required result
ns/op 92365 74010 −19.6% (−18121) −21099 to −17692 ≤ 4618 PASSED
MB/s 6441 8039 +24.7% (+1593) +1528 to +1799 ≥ −322.1 PASSED

Per-row maximum x_vs_best and entrant counts for all 38 BenchmarkBar rows on the current pinned field · 10 sample pairs

metric baseline candidate paired median change confidence range required result
bar_multi_multi_N1_unicode_pair_miss_1_5mb_worst_x_vs_best 0.7372 0.7344 −0.0018 −0.0113 to +0.0084 ≤ 0.03686 PASSED
bar_multi_multi_N2_miss_log_1mb_worst_x_vs_best 0.8101 0.8103 +0.0032 −0.0081 to +0.0104 ≤ 0.04051 PASSED
bar_multi_multi_N512_miss_hazard_64kb_worst_x_vs_best 0.509 0.5086 −0.00195 −0.0037 to +0.0042 ≤ 0.02545 PASSED
bar_multi_multi_N512_miss_log_64kb_worst_x_vs_best 0.6676 0.6673 −0.0003 −0.0023 to +0.0035 ≤ 0.03338 PASSED
bar_multi_multi_N5_raw_transition_late_hit_5mb_worst_x_vs_best 0.9682 0.9675 +0.00145 −0.0031 to +0.0176 ≤ 0.04841 PASSED
bar_multi_multi_N5_raw_transition_miss_5mb_worst_x_vs_best 0.9743 0.9727 −0.0006 −0.0024 to +0.0049 ≤ 0.04871 PASSED
bar_multi_multi_N64_miss_log_64kb_worst_x_vs_best 0.8169 0.816 −0.0007 −0.0047 to +0.0026 ≤ 0.04085 PASSED
bar_multi_multi_N64_miss_ru_64kb_worst_x_vs_best 0.6068 0.6063 −0.00025 −0.0013 to +0.0019 ≤ 0.03034 PASSED
bar_multi_multi_N8_hazard_hit_1mb_worst_x_vs_best 0.8699 0.8721 −0.00145 −0.0236 to +0.0133 ≤ 0.0435 PASSED
bar_multi_multi_N8_hit_log_1mb_worst_x_vs_best 0.4356 0.4329 −0.0029 −0.013 to 0 ≤ 0.02178 PASSED
bar_multi_multi_N8_miss_hazard_1mb_worst_x_vs_best 0.3293 0.3302 +0.0006 −0.0101 to +0.0037 ≤ 0.01647 PASSED
bar_multi_multi_N8_miss_log_1mb_worst_x_vs_best 0.502 0.5029 +0.0027 −0.0022 to +0.0048 ≤ 0.0251 PASSED
bar_multi_multi_N8_miss_ru_1mb_worst_x_vs_best 0.6092 0.6085 +0.0017 −0.0033 to +0.0033 ≤ 0.03046 PASSED
bar_multi_multi_forms4_complete_triple_miss_1mb_worst_x_vs_best 0.9081 0.5011 −44.7% (−0.4058) −0.4551 to −0.3713 ≤ 0.04541 PASSED
bar_multi_multi_forms8_complete_triple_near_miss_64kb_worst_x_vs_best 0.5626 0.2971 −47.1% (−0.2652) −0.2679 to −0.2599 ≤ 0.02813 PASSED
bar_single_code_hit_brackets_256kb_worst_x_vs_best 0.5755 0.5758 −0.0009 −0.0039 to +0.0046 ≤ 0.02877 PASSED
bar_single_code_miss_256kb_worst_x_vs_best 0.5226 0.5234 +0.00005 −0.0045 to +0.0028 ≤ 0.02613 PASSED
bar_single_kelvin_hazard_1mb_worst_x_vs_best 0.4256 0.4243 −0.00105 −0.0027 to +0.001 ≤ 0.02128 PASSED
bar_single_latency_match_end_1kb_worst_x_vs_best 0.6484 0.6512 +0.4% (+0.00275) +0.0007 to +0.0066 ≤ 0.03242 PASSED
bar_single_latency_match_mid_1kb_worst_x_vs_best 0.7296 0.7309 +0.00105 −0.0001 to +0.0059 ≤ 0.03648 PASSED
bar_single_latency_match_start_1kb_worst_x_vs_best 0.8536 0.8509 −0.003 −0.0048 to +0.0009 ≤ 0.04268 PASSED
bar_single_latency_miss_1kb_worst_x_vs_best 0.6661 0.6634 −0.4% (−0.0026) −0.0036 to −0.0006 ≤ 0.0333 PASSED
bar_single_log_hit_sparse_1mb_worst_x_vs_best 0.3623 0.3634 +0.0011 −0.0009 to +0.0025 ≤ 0.01812 PASSED
bar_single_log_miss_1kb_worst_x_vs_best 0.6563 0.6529 −0.0025 −0.0118 to +0.0028 ≤ 0.03282 PASSED
bar_single_log_miss_1mb_worst_x_vs_best 0.9115 0.9074 −0.4% (−0.00355) −0.013 to −0.0001 ≤ 0.04558 PASSED
bar_single_log_miss_64kb_worst_x_vs_best 0.8669 0.8675 −0.00185 −0.0042 to +0.0044 ≤ 0.04334 PASSED
bar_single_log_needle16_64kb_worst_x_vs_best 0.7196 0.7189 +0.00035 −0.0051 to +0.0028 ≤ 0.03598 PASSED
bar_single_log_needle32_64kb_worst_x_vs_best 0.4302 0.4301 +0.00015 −0.0028 to +0.0042 ≤ 0.02151 PASSED
bar_single_log_needle3_64kb_worst_x_vs_best 0.8611 0.8619 −0.0005 −0.0028 to +0.0037 ≤ 0.04305 PASSED
bar_single_log_needle8_64kb_worst_x_vs_best 0.4307 0.4303 −0.00025 −0.0023 to +0.0008 ≤ 0.02153 PASSED
bar_single_periodic_miss_64kb_worst_x_vs_best 0.828 0.8281 +0.0002 −0.0015 to +0.0019 ≤ 0.0414 PASSED
bar_single_prose_hit_dense_1mb_worst_x_vs_best 0.5307 0.5324 +0.00165 −0.0058 to +0.0102 ≤ 0.02654 PASSED
bar_single_prose_miss_1mb_worst_x_vs_best 0.4195 0.4189 −0.0005 −0.002 to +0.001 ≤ 0.02098 PASSED
bar_single_ru_hit_sparse_1mb_worst_x_vs_best 0.8096 0.8234 +1.6% (+0.013) +0.0057 to +0.0197 ≤ 0.04048 PASSED
bar_single_ru_latency_miss_1kb_worst_x_vs_best 0.8731 0.8718 −0.0007 −0.0082 to +0.0055 ≤ 0.04366 PASSED
bar_single_ru_miss_1mb_worst_x_vs_best 0.8609 0.8594 0 −0.0046 to +0.0073 ≤ 0.04304 PASSED
bar_single_samechar_miss_64kb_worst_x_vs_best 0.6855 0.6878 +0.0014 −0.0024 to +0.0056 ≤ 0.03428 PASSED
bar_single_torture_miss_64kb_worst_x_vs_best 0.0394 0.0393 −0.00019 −0.00035 to +0.00014 ≤ 0.00197 PASSED
bar_multi_multi_N1_unicode_pair_miss_1_5mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N2_miss_log_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N512_miss_hazard_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N512_miss_log_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N5_raw_transition_late_hit_5mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N5_raw_transition_miss_5mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N64_miss_log_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N64_miss_ru_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_hazard_hit_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_hit_log_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_miss_hazard_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_miss_log_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_miss_ru_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_forms4_complete_triple_miss_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_forms8_complete_triple_near_miss_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_code_hit_brackets_256kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_code_miss_256kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_kelvin_hazard_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_latency_match_end_1kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_latency_match_mid_1kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_latency_match_start_1kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_latency_miss_1kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_hit_sparse_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_miss_1kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_miss_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_miss_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle16_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle32_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle3_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle8_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_periodic_miss_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_prose_hit_dense_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_prose_miss_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_ru_hit_sparse_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_ru_latency_miss_1kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_ru_miss_1mb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_samechar_miss_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_single_torture_miss_64kb_all_samples_win 1 1 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N1_unicode_pair_miss_1_5mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N2_miss_log_1mb_entrants 8 8 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N512_miss_hazard_64kb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N512_miss_log_64kb_entrants 8 8 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N5_raw_transition_late_hit_5mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N5_raw_transition_miss_5mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N64_miss_log_64kb_entrants 8 8 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N64_miss_ru_64kb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_hazard_hit_1mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_hit_log_1mb_entrants 8 8 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_miss_hazard_1mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_miss_log_1mb_entrants 8 8 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_N8_miss_ru_1mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_forms4_complete_triple_miss_1mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_multi_multi_forms8_complete_triple_near_miss_64kb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_single_code_hit_brackets_256kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_code_miss_256kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_kelvin_hazard_1mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_single_latency_match_end_1kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_latency_match_mid_1kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_latency_match_start_1kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_latency_miss_1kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_hit_sparse_1mb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_miss_1kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_miss_1mb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_miss_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle16_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle32_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle3_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_log_needle8_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_periodic_miss_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_prose_hit_dense_1mb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_prose_miss_1mb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_ru_hit_sparse_1mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_single_ru_latency_miss_1kb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_single_ru_miss_1mb_entrants 6 6 0 0 to 0 ≥ 0 PASSED
bar_single_samechar_miss_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED
bar_single_torture_miss_64kb_entrants 7 7 0 0 to 0 ≥ 0 PASSED

Checks: 14 of 14 passed. Verification: no defect found.

Timeline