mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 08:47:28 +01:00
Reduce the deflate decoder Huffman table size
name old speed new speed delta wuffs_deflate_decode_1k/clang5 138MB/s ± 0% 140MB/s ± 1% +1.16% (p=0.008 n=5+5) wuffs_deflate_decode_10k/clang5 228MB/s ± 1% 229MB/s ± 1% ~ (p=0.222 n=5+5) wuffs_deflate_decode_100k_just_one_read/clang5 267MB/s ± 1% 267MB/s ± 1% ~ (p=0.690 n=5+5) wuffs_deflate_decode_100k_many_big_reads/clang5 225MB/s ± 0% 225MB/s ± 0% ~ (p=0.310 n=5+5) wuffs_deflate_decode_1k/gcc7 157MB/s ± 0% 157MB/s ± 0% ~ (p=0.730 n=4+5) wuffs_deflate_decode_10k/gcc7 269MB/s ± 0% 269MB/s ± 1% ~ (p=0.222 n=5+5) wuffs_deflate_decode_100k_just_one_read/gcc7 321MB/s ± 0% 321MB/s ± 1% ~ (p=0.548 n=5+5) wuffs_deflate_decode_100k_many_big_reads/gcc7 254MB/s ± 0% 254MB/s ± 0% ~ (p=0.421 n=5+5) wuffs_gzip_decode_10k/clang5 205MB/s ± 0% 212MB/s ± 0% +3.50% (p=0.016 n=5+4) wuffs_gzip_decode_100k/clang5 238MB/s ± 0% 245MB/s ± 0% +3.31% (p=0.008 n=5+5) wuffs_gzip_decode_10k/gcc7 247MB/s ± 0% 248MB/s ± 0% +0.47% (p=0.016 n=5+5) wuffs_gzip_decode_100k/gcc7 293MB/s ± 1% 293MB/s ± 0% ~ (p=0.690 n=5+5) wuffs_zlib_decode_10k/clang5 210MB/s ± 0% 210MB/s ± 0% ~ (p=0.056 n=5+5) wuffs_zlib_decode_100k/clang5 244MB/s ± 0% 244MB/s ± 0% ~ (p=0.556 n=4+5) wuffs_zlib_decode_10k/gcc7 247MB/s ± 0% 249MB/s ± 1% +0.77% (p=0.008 n=5+5) wuffs_zlib_decode_100k/gcc7 288MB/s ± 0% 288MB/s ± 0% ~ (p=1.000 n=5+5)
This commit is contained in:
1 parent
670b45be53
commit
92f3958a28
4 files changed
+16
-16
No files matched your search
@@ -53,9 +53,9 @@ pri const dcode_magic_numbers array[32] base.u32 = [
|
||||
0x401000B0, 0x401800B0, 0x402000C0, 0x403000C0, 0x404000D0, 0x406000D0, 0x08000000, 0x08000000,
|
||||
]
|
||||
|
||||
// TODO: replace the magic "big enough" 1234 with something more principled,
|
||||
// TODO: replace the magic "big enough" 1024 with something more principled,
|
||||
// perhaps discovered via an exhaustive search.
|
||||
pri const huffs_table_size base.u32 = 1234
|
||||
pri const huffs_table_size base.u32 = 1024
|
||||
|
||||
pub struct decoder?(
|
||||
// These fields yield src's bits in Least Significant Bits order.
|
||||
@@ -771,7 +771,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
||||
if (top + ((1 as base.u32) << j)) > huffs_table_size {
|
||||
return "?internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
assert (top + ((1 as base.u32) << j)) <= 1234 via "a <= b: a <= c; c <= b"(c:huffs_table_size)
|
||||
assert (top + ((1 as base.u32) << j)) <= 1024 via "a <= b: a <= c; c <= b"(c:huffs_table_size)
|
||||
next_top = top + ((1 as base.u32) << j)
|
||||
|
||||
redirect_key = (reverse8[redirect_key >> 1] as base.u32) | ((redirect_key & 1) << 8)
|
||||
@@ -819,7 +819,7 @@ pri func decoder.init_huff!(which base.u32[..1], n_codes0 base.u32[..320], n_cod
|
||||
if (top + ((high_bits | reversed_key) & 511)) >= huffs_table_size {
|
||||
return "?internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
assert (top + ((high_bits | reversed_key) & 511)) < 1234 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
assert (top + ((high_bits | reversed_key) & 511)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
this.huffs[args.which][top + ((high_bits | reversed_key) & 511)] = value
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||
return "?internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
assert (redir_top + (bits & redir_mask)) < 1234 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
table_entry = this.huffs[0][redir_top + (bits & redir_mask)]
|
||||
table_entry_n_bits = table_entry & 0x0F
|
||||
bits >>= table_entry_n_bits
|
||||
@@ -247,7 +247,7 @@ pri func decoder.decode_huffman_fast!(dst base.io_writer, src base.io_reader) ba
|
||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||
return "?internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
assert (redir_top + (bits & redir_mask)) < 1234 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
table_entry = this.huffs[1][redir_top + (bits & redir_mask)]
|
||||
table_entry_n_bits = table_entry & 0x0F
|
||||
bits >>= table_entry_n_bits
|
||||
|
||||
@@ -82,7 +82,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||
return "?internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
assert (redir_top + (bits & redir_mask)) < 1234 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
table_entry = this.huffs[0][redir_top + (bits & redir_mask)]
|
||||
table_entry_n_bits = table_entry & 0x0F
|
||||
if n_bits >= table_entry_n_bits {
|
||||
@@ -164,7 +164,7 @@ pri func decoder.decode_huffman_slow?(dst base.io_writer, src base.io_reader) {
|
||||
if (redir_top + (bits & redir_mask)) >= huffs_table_size {
|
||||
return "?internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
assert (redir_top + (bits & redir_mask)) < 1234 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
assert (redir_top + (bits & redir_mask)) < 1024 via "a < b: a < c; c <= b"(c:huffs_table_size)
|
||||
table_entry = this.huffs[1][redir_top + (bits & redir_mask)]
|
||||
table_entry_n_bits = table_entry & 0x0F
|
||||
if n_bits >= table_entry_n_bits {
|
||||
|
||||
Reference in new issue
Block a user