Repository navigation
zstd: keep default-encoder hash primes in registers on arm64 - #1241
Conversation
Apply the better encoder's treatment to doubleFastEncoder and doubleFastEncoderDict, which hash with the same two primes. The primes are loaded once per Encode through hashPrimes8and5, now shared in hash.go, and dFastHashL/dFastHashS replace hashLen in the encode loops. Reset and ResetPrefix keep hashLen. Output is byte-identical to master (8 corpora x default/better, arm64 and amd64). The better encoder's code generation is unchanged. Default level, 4 MiB frames, benchstat MB/s vs master: Graviton2 +4.4%, Graviton3 +2.1%, Graviton4 +1.9%, Sapphire Rapids ~ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe zstd better and double-fast encoders now use shared hash primes and prime-based hash helpers. The hash-helper test checks the better and double-fast long- and short-hash results against ChangesZstd hash helper updates
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~12 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The identified repeat-offset path does not require a fix, and no actionable merge-blocking issue remains after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Speeds up
SpeedDefaultencoding on arm64 (+2–4%) with byte-identical output, by giving the default-level encoder the same hash-prime treatment as the better encoder got in #1230. amd64 is unchanged.Changes (362a8de)
doubleFastEncoderanddoubleFastEncoderDicthash with the same two 64-bit primes asbetterFastEncoder. On arm64 each prime takes 4 instructions to build, and the compiler rebuilds it at every use.betterHashPrimesbecomeshashPrimes8and5inhash.go, shared by both encoders. It still loads the primes from a package var only whenhashPrimesInRegsis set (arm64), and returns the constants elsewhere.dFastHashL/dFastHashSreplacehashLenin the default encoders' loops, taking the primes as arguments.ResetandResetPrefixkeephashLen.Why output is unchanged
dFastHashL/dFastHashScompute exactly whathashLencomputes for these table sizes.TestBetterHashMatchesHashLeninencoder_test.gobecomesTestHashHelpersMatchHashLenand gains the two default-encoder cases.Benchmarks
Same setup as #1230: 32 MiB decompressed prefixes of your real corpora, each encoded as 4 MiB
EncodeAllframes with a 4 MiB window, CRC on and concurrency 1. Each result is 10 master/PR rounds, alternating within each round, on one pinned core, compared withbenchstat. Figures areSpeedDefaultMB/s vs master;~means not significant.The arm64 cells are all improvements, and all are significant except the
~ones. On amd64 the helpers return the constants, so the hashing is the same as master's; the one borderline Sapphire Rapids cell sits at the edge of significance, and the other seven are flat.These runs were taken together with #1230's; that PR does not touch the default encoder, so the
SpeedDefaultrows measure this change alone.🤖 Generated with Claude Code
Summary by CodeRabbit