mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Extend std/deflate ringbuffer to simplify copies
name old speed new speed delta wuffs_deflate_decode_1k_full_init/clang5 155MB/s ± 1% 154MB/s ± 0% -0.98% (p=0.000 n=10+9) wuffs_deflate_decode_1k_part_init/clang5 190MB/s ± 0% 193MB/s ± 1% +1.49% (p=0.000 n=10+9) wuffs_deflate_decode_10k_full_init/clang5 240MB/s ± 0% 249MB/s ± 0% +3.68% (p=0.000 n=9+10) wuffs_deflate_decode_10k_part_init/clang5 247MB/s ± 0% 257MB/s ± 1% +4.03% (p=0.000 n=10+10) wuffs_deflate_decode_100k_just_one_read/clang5 292MB/s ± 1% 291MB/s ± 0% -0.34% (p=0.043 n=10+9) wuffs_deflate_decode_100k_many_big_reads/clang5 246MB/s ± 0% 250MB/s ± 0% +1.77% (p=0.000 n=9+10) wuffs_deflate_decode_1k_full_init/gcc9 166MB/s ± 1% 165MB/s ± 1% -0.48% (p=0.009 n=10+10) wuffs_deflate_decode_1k_part_init/gcc9 208MB/s ± 1% 212MB/s ± 0% +1.85% (p=0.000 n=10+9) wuffs_deflate_decode_10k_full_init/gcc9 248MB/s ± 1% 281MB/s ± 0% +13.05% (p=0.000 n=9+10) wuffs_deflate_decode_10k_part_init/gcc9 256MB/s ± 0% 290MB/s ± 0% +13.34% (p=0.000 n=10+10) wuffs_deflate_decode_100k_just_one_read/gcc9 336MB/s ± 0% 333MB/s ± 0% -0.93% (p=0.000 n=9+8) wuffs_deflate_decode_100k_many_big_reads/gcc9 262MB/s ± 0% 280MB/s ± 1% +6.99% (p=0.000 n=9+10)
This commit is contained in:
1 parent
771d4f9d98
commit
e65c861207
5 files changed
+80
-69
No files matched your search
@@ -30,7 +30,6 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader)
|
||||
var redir_mask : base.u32[..= 0x7FFF]
|
||||
var length : base.u32[..= 258]
|
||||
var dist_minus_1 : base.u32[..= 0x7FFF]
|
||||
var n_copied : base.u32
|
||||
var hlen : base.u32[..= 0x7FFF]
|
||||
var hdist : base.u32
|
||||
|
||||
@@ -284,7 +283,6 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader)
|
||||
bits >>= table_entry_n_bits
|
||||
n_bits -= table_entry_n_bits
|
||||
|
||||
n_copied = 0
|
||||
// The "while true { etc; break }" is a redundant version of "etc", but
|
||||
// its presence minimizes the diff between decode_huffman_fast and
|
||||
// decode_huffman_slow.
|
||||
@@ -314,31 +312,13 @@ pri func decoder.decode_huffman_fast!(dst: base.io_writer, src: base.io_reader)
|
||||
// start copying from.
|
||||
hdist = this.history_index - hdist
|
||||
|
||||
// Copy from hdist to the end of this.history, and then
|
||||
// possibly wrap around the this.history ringbuffer.
|
||||
// Copy from hdist to the end of this.history.
|
||||
//
|
||||
// This copying is simpler than the decode_huffman_slow version
|
||||
// because it cannot yield. We have already checked that
|
||||
// args.dst.available() is large enough.
|
||||
//
|
||||
// The "while true { etc; break }" is a redundant version of
|
||||
// "etc", but its presence minimizes the diff between
|
||||
// decode_huffman_fast and decode_huffman_slow.
|
||||
while true,
|
||||
inv args.dst.available() >= 258,
|
||||
{
|
||||
// TODO: copy_from_slice32 should probably update the
|
||||
// "args.dst.available() >= 258" fact. It should certainly
|
||||
// invalidate any fact that was "<=" instead of ">=".
|
||||
n_copied = args.dst.copy_n32_from_slice!(
|
||||
n: hlen, s: this.history[hdist & 0x7FFF ..])
|
||||
if hlen <= n_copied {
|
||||
break
|
||||
}
|
||||
hlen -= n_copied
|
||||
args.dst.copy_n32_from_slice!(n: hlen, s: this.history[..])
|
||||
break
|
||||
}
|
||||
args.dst.copy_n32_from_slice!(
|
||||
n: hlen, s: this.history[hdist & 0x7FFF ..])
|
||||
|
||||
if length == 0 {
|
||||
// No need to copy from args.dst.
|
||||
|
||||
Reference in new issue
Block a user