Repository navigation
Conversation
The core inflate hot spot decode_huffman_code_block_stateless previously had only a C baseline implementation; frequent memory accesses to the hot state and call overhead across helper functions hurt inflate performance. Rewrite it as a single RISC-V assembly function (igzip_decode_huffman_code_block_riscv64.S): the hot state fields (read_in/next_out/avail_in and 9 others) are kept resident in the callee-saved registers s0-s11, eliminating the per-symbol memory round trips and function call overhead of the C version. Performance measured with igzip_perf on K3 (SpacemiT X100), silesia.tar, -s -f <level> -y <flush> -b 1024, serial run on an idle board: igzip_perf -s -f 0 -y 1 -b 1024 silesia.tar (22.4% performance improvement) new: isal_stateful_inflate-> runtime = 4460903 usecs, bandwidth 423 MB in 4.4609 sec = 95.03 MB/s old: isal_stateful_inflate-> runtime = 5462228 usecs, bandwidth 423 MB in 5.4622 sec = 77.61 MB/s igzip_perf -s -f 0 -y 2 -b 1024 silesia.tar (39.7% performance improvement) new: isal_stateful_inflate-> runtime = 5492285 usecs, bandwidth 423 MB in 5.4923 sec = 77.18 MB/s old: isal_stateful_inflate-> runtime = 3837294 usecs, bandwidth 211 MB in 3.8373 sec = 55.24 MB/s igzip_perf -s -f 1 -y 1 -b 1024 silesia.tar (10.1% performance improvement) new: isal_stateful_inflate-> runtime = 3508576 usecs, bandwidth 211 MB in 3.5086 sec = 60.41 MB/s old: isal_stateful_inflate-> runtime = 3863336 usecs, bandwidth 211 MB in 3.8633 sec = 54.86 MB/s igzip_perf -s -f 1 -y 2 -b 1024 silesia.tar (16.9% performance improvement) new: isal_stateful_inflate-> runtime = 4500793 usecs, bandwidth 211 MB in 4.5008 sec = 47.09 MB/s old: isal_stateful_inflate-> runtime = 5261334 usecs, bandwidth 211 MB in 5.2613 sec = 40.29 MB/s Deflate shows no performance change at any level, and the compression ratio matches the baseline under all conditions (the output stream is byte-identical). All tests successful: PASS: igzip/igzip_rand_test PASS: igzip/igzip_inflate_test Also verified on the K1 (SpacemiT X60) board: functional tests pass and the performance improvement direction matches K3. Signed-off-by: DuanZhizhong <duan.zhizhong@zte.com.cn>
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.
Summary
Implements
decode_huffman_code_block_stateless— the dominant inflatehot spot (90%+ of inflate time) — in RV64 assembly. The hot state fields
(read_in/next_out/avail_in and 9 others) are kept resident in the
callee-saved registers s0-s11, eliminating the per-symbol memory round
trips and function call overhead of the C version.
Performance
igzip_perf -s -f -y -b 1024, silesia.tar,
K3 (SpacemiT X100), idle board, serial run:
Deflate: no performance change at any level, and the compression ratio
matches the baseline under all conditions (the output stream is
byte-identical).
Also verified on K1 (SpacemiT X60): functional tests pass and the
performance improvement direction matches K3.
Testing
Related: #431 (compare258, same igzip/riscv64 port)