Skip to content

igzip/riscv64: implement decode_huffman_code_block_stateless in assembly - #473

Open
beimian66 wants to merge 1 commit into
intel:masterfrom
zte-riscv:optimize-inflate
Open

beimian66 wants to merge 1 commit into
intel:masterfrom
zte-riscv:optimize-inflate

Conversation

@beimian66

Copy link
Copy Markdown

Summary

Implements decode_huffman_code_block_stateless — the dominant inflate
hot 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:

case baseline (MB/s) with patch (MB/s) gain
f0 y1 77.61 95.03 +22.4%
f0 y2 55.24 77.18 +39.7%
f1 y1 54.86 60.41 +10.1%
f1 y2 40.29 47.09 +16.9%

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

  • igzip_rand_test: PASS
  • igzip_inflate_test: PASS
  • Covered by the RISC-V QEMU CI job.

Related: #431 (compare258, same igzip/riscv64 port)

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>
@tkanteck tkanteck added the riscv label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants