Repository navigation
Conversation
ihb2032
force-pushed
the
riscv-prefetch-gate
branch
2 times, most recently
from
December 3, 2026 01:50
47ae715 to
06abc24
Compare
Co-authored-by: lyd1992 <liuyudong@iscas.ac.cn> Co-authored-by: YuanSheng <yuansheng@isrc.iscas.ac.cn>
ihb2032
force-pushed
the
riscv-prefetch-gate
branch
from
December 4, 2026 03:46
06abc24 to
4ae304f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
This PR adds an RISC-V-specific frame-size gate for zstd's existing long (prefetch) decoder, and deepens its sequence ring when the build targets Zicbop.
Upstream only selects
ZSTD_decompressSequencesLongfor cold dictionaries or when a large share of the offsets is long. On RV64 cores with a small shared L2, a large frame's output stream and match source compete for the cache, so the declared frame content size is a useful additional signal. The gate uses the frame header's content size: a known size of at leastZSTD_RISCV_PREFETCH_MIN_FRAME(default 4 MiB, overrideable at build time) selects the long decoder; unknown sizes keep the upstream heuristics. The build-time override is documented inlib/README.md. With Zicbop,PREFETCH_*emits real prefetch instructions and the sequence ring grows from 8 to 256 entries; without Zicbop the code compiles to the upstream behavior. Only decoder selection changes; compressed output is unchanged.Related work: #4557/#5053/#4733 already generalize the prevOffset hoisting (the RISC-V numbers can be added there; this PR does not duplicate it); #4643 extends
PREFETCH_L1(match)in the decoder; #5067 tunes the decode copy/prefetch; #1411 introduced the cold-dictionary path of the long decoder; #3828 prefetchesop/litPtrin the sequence loop. No open PR covers a frame-size gate/deep ring for small-L2 RISC-V + Zicbop.Performance (decoder-only; frames produced by unmodified upstream
devate50cdb0d4; SG2044, 64x RV64GCV, 2 MB L2 per 4 cores; GCC 15.1; flags-O3 -march=rv64gcv_zbb_zba_zicbop; single coretaskset -c 8; 5 interleaved rounds, medians; no checksum; real Chinese public-domain text):L19:
L9:
L1/L3 are 0.94-1.01x and 1.03-1.23x respectively. Frames below the 4 MB gate keep the short decoder; on the 3.59 MB corpus lowering the gate to 2 MB gives +9.8% (L9) and +12.1% (L19) at -4.6% (L1), which is the main review question for the default threshold.
The patch also adds a unit test that decodes frames above and below the gate, plus a frame with unknown content size.
Checklist
reviewed; related work is listed above, and no PR covers this frame-size
gate.
with CPU, compiler, flags and data stated.
Tools used
AI-assisted tools were used for analysis, implementation and benchmark scripting. All measurements, code and conclusions were reviewed by the author.