Tweak std/bzip2 flush_* basic blocks

name                             old speed      new speed      delta

wuffs_bzip2_decode_10k/clang11   65.2MB/s ± 0%  65.2MB/s ± 0%    ~     (p=0.056 n=5+5)
wuffs_bzip2_decode_100k/clang11  52.4MB/s ± 0%  51.5MB/s ± 0%  -1.67%  (p=0.016 n=5+4)

wuffs_bzip2_decode_10k/gcc10     60.6MB/s ± 0%  61.7MB/s ± 0%  +1.81%  (p=0.008 n=5+5)
wuffs_bzip2_decode_100k/gcc10    49.2MB/s ± 0%  49.6MB/s ± 0%  +0.86%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2022-05-24 12:01:30 +10:00
1 parent bed155bd6f
commit 6a3e43f495
3 files changed
+40 -24

No files matched your search

+10 -7
View File
@@ -29,11 +29,10 @@ pri func decoder.flush_fast!(dst: base.io_writer) {
block_size = this.block_size
while (block_size > 0) and (args.dst.length() > 255) {
entry = this.bwt[flush_pointer]
curr = (entry & 0xFF) as base.u8
flush_pointer = entry >> 12
if flush_repeat_count < 4 {
entry = this.bwt[flush_pointer]
curr = (entry & 0xFF) as base.u8
flush_pointer = entry >> 12
if curr == flush_prev {
flush_repeat_count += 1
} else {
@@ -43,8 +42,13 @@ pri func decoder.flush_fast!(dst: base.io_writer) {
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
(block_checksum_have ~mod<< 8)
args.dst.write_u8_fast!(a: curr)
flush_prev = curr
block_size -= 1
} else {
entry = this.bwt[flush_pointer]
curr = (entry & 0xFF) as base.u8
flush_pointer = entry >> 12
flush_repeat_count = curr as base.u32
while flush_repeat_count > 0,
inv block_size > 0,
@@ -58,10 +62,9 @@ pri func decoder.flush_fast!(dst: base.io_writer) {
flush_repeat_count -= 1
} endwhile
flush_repeat_count = 0
flush_prev = curr
block_size -= 1
}
flush_prev = curr
block_size -= 1
} endwhile
this.flush_pointer = flush_pointer
+10 -7
View File
@@ -29,11 +29,10 @@ pri func decoder.flush_slow?(dst: base.io_writer) {
block_size = this.block_size
while (block_size > 0) and (not coroutine_resumed) {
entry = this.bwt[flush_pointer]
curr = (entry & 0xFF) as base.u8
flush_pointer = entry >> 12
if flush_repeat_count < 4 {
entry = this.bwt[flush_pointer]
curr = (entry & 0xFF) as base.u8
flush_pointer = entry >> 12
if curr == flush_prev {
flush_repeat_count += 1
} else {
@@ -43,8 +42,13 @@ pri func decoder.flush_slow?(dst: base.io_writer) {
REV_CRC32_TABLE[((block_checksum_have >> 24) as base.u8) ^ curr] ^
(block_checksum_have ~mod<< 8)
args.dst.write_u8?(a: curr)
flush_prev = curr
block_size -= 1
} else {
entry = this.bwt[flush_pointer]
curr = (entry & 0xFF) as base.u8
flush_pointer = entry >> 12
flush_repeat_count = curr as base.u32
while flush_repeat_count > 0,
inv block_size > 0,
@@ -56,10 +60,9 @@ pri func decoder.flush_slow?(dst: base.io_writer) {
flush_repeat_count -= 1
} endwhile
flush_repeat_count = 0
flush_prev = curr
block_size -= 1
}
flush_prev = curr
block_size -= 1
} endwhile
this.flush_pointer = flush_pointer