Introduce std/bzip2 decoder.flush_fast method

Compared to the recent commit 623290ef "Cache std/bzip2 Huffman tree
lookup":

name                             old speed      new speed      delta

wuffs_bzip2_decode_10k/clang11   60.5MB/s ± 0%  60.5MB/s ± 0%    ~     (p=1.000 n=5+5)
wuffs_bzip2_decode_100k/clang11  46.7MB/s ± 1%  45.7MB/s ± 1%  -2.05%  (p=0.008 n=5+5)

wuffs_bzip2_decode_10k/gcc10     58.7MB/s ± 0%  58.5MB/s ± 0%    ~     (p=0.222 n=5+5)
wuffs_bzip2_decode_100k/gcc10    46.9MB/s ± 0%  46.3MB/s ± 0%  -1.46%  (p=0.008 n=5+5)
This commit is contained in:
Nigel Tao committed 2022-05-24 11:50:48 +10:00
1 parent 29eec43287
commit 66f194f7e0
4 files changed
+309 -106

No files matched your search

+30 -1
View File
@@ -43,7 +43,12 @@ pub struct decoder? implements base.io_transformer(
decode_huffman_section : base.u32,
decode_huffman_run_shift : base.u32[..= 23],
flush_pointer : base.u32[..= 1_048575],
flush_repeat_count : base.u32[..= 255],
flush_prev : base.u8,
final_checksum_have : base.u32,
block_checksum_have : base.u32,
block_checksum_want : base.u32,
original_pointer : base.u32,
num_symbols : base.u32[..= 258],
@@ -174,7 +179,31 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf
} endwhile
this.invert_bwt!()
this.flush_block?(dst: args.dst)
this.block_checksum_have = 0xFFFF_FFFF
if this.original_pointer >= this.block_size {
return "#bad block length"
}
assert this.original_pointer < 900000 via "a < b: a < c; c <= b"(c: this.block_size)
this.flush_pointer = this.bwt[this.original_pointer] >> 12
this.flush_repeat_count = 0
this.flush_prev = 0
while this.block_size > 0 {
this.flush_fast!(dst: args.dst)
if this.block_size <= 0 {
break
}
this.flush_slow?(dst: args.dst)
} endwhile
this.block_checksum_have ^= 0xFFFF_FFFF
if this.block_checksum_have <> this.block_checksum_want {
return "#bad checksum"
}
this.final_checksum_have = this.block_checksum_have ^ (
(this.final_checksum_have >> 31) |
(this.final_checksum_have ~mod<< 1))
} endwhile
// Read the 32-bit final checksum.