Repository navigation
huff0: align the decode inner loops to 64 bytes - #1236
Conversation
The honeycombio/avo fork adds a PCALIGN pseudo-instruction that the arm64 lowering passes through. The regenerated assembly is byte-identical. The newer avo requires newer golang.org/x modules, which require go 1.25.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Place PCALIGN $64 before the 4X and 1X inner loops, which also raises each function's alignment to 64. Without it the loop heads land wherever the linker places the function, and the same code measured about ±2% apart between builds that differed only in what came before it. The padding runs once per outer iteration. 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 ignored due to path filters (1)
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughGenerated and AMD64 Huff0 decompression inner loops now use 64-byte alignment. ARM64 loops cap batch counts by available input and output capacity. ChangesHuff0 decompression loops
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The reviewed changes add loop alignment without an identified behavioral regression. The PR appears mergeable after normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
The same alignment for the zstd sequence decode/execute loops is staged on top of #1212: honeycombio/compress@lizf.zstd-twopass-prefetch...lizf.zstd-pcalign-on-1212. It touches the same generator lines as #1212, so I'll open it once #1212 is merged. While staging it I hit a Go assembler bug, in the case you reported in golang/go#74648: a label directly on a The staged zstd change therefore emits the |
The honeycombio/avo fork now rejects a label placed directly on a PCALIGN, which the amd64 assembler mishandles (golang/go#74648, golang/go#81792). The regenerated assembly is byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
klauspost
left a comment
There was a problem hiding this comment.
Huge alignment. OK for the inner loop, though. Wondering if we should insert a JMP to the aligned part, so the CPU can skip the alignment code?
|
I don't think a JMP would help here. The padding runs rarely, and it's cheaper to run than a jump would be.
On "huge": |
|
It is fine. Just wondering. Some day I may do actual tests. I don't think your AI's analysis is more than speculation. Instruction decoding will be less with a JMP - and of course it is fully predictable. Anyway, doesn't matter, but up to 63 bytes of padding will be quite a bit. |
Aligns the huff0 decode inner loops to 64 bytes. This makes their performance independent of where the linker happens to place the functions; it does not claim a speedup.
(1) Move the asm generator to the current avo arm64 fork (71a6b98)
The honeycombio/avo fork's arm64 lowering now supports the
PCALIGNpseudo-instruction and passes it through to the arm64 output. The regenerateddecompress_amd64.sanddecompress_arm64.sare byte-identical. The newer avo requires newergolang.org/xmodules, which requirego 1.25.0in_generate/go.mod.(2) Align the decode inner loops to 64 bytes (7b131b4)
PCALIGN $64is placed before theinner_loopof each 4X and 1X decode loop: 12 functions on amd64 and 6 on arm64. It also raises each function's alignment to 64.TEXTsymbol to 64 bytes.PCALIGN $0x40lines, the.sdiff is column re-alignment in the arm64 printer's output, becausePCALIGNis the longest mnemonic. The diff with-wshows only the added lines.(3) Move the generator to avo with the PCALIGN label check (48b49bf)
The avo fork now fails generation if a label sits directly on a
PCALIGN. That placement makes the amd64 assembler misroute the jump (golang/go#74648) or, since Go 1.26, loop forever when it widens a branch (golang/go#81792). None of this PR'sPCALIGNs has a label before it, and the regenerated assembly is byte-identical.The same change for the zstd sequence loops will follow separately. It touches the same generator lines as #1212, so it waits for that to merge.
Tests:
go test ./huff0 ./zstdpass on amd64 (Zen 3) and arm64 (Neoverse-N1). With-tags noasm, huff0 passes on amd64 and zstd on arm64.🤖 Generated with Claude Code
Summary by CodeRabbit