mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Remove some suspensions from decode_huffman_fast.
name old speed new speed delta puffs_adler32_10k/clang 2.40GB/s ± 3% 2.45GB/s ± 0% +2.21% (p=0.000 n=10+10) puffs_adler32_100k/clang 2.41GB/s ± 1% 2.46GB/s ± 0% +2.05% (p=0.000 n=9+10) puffs_flate_decode_1k/clang 127MB/s ± 1% 137MB/s ± 0% +7.94% (p=0.000 n=9+9) puffs_flate_decode_10k/clang 177MB/s ± 1% 177MB/s ± 0% ~ (p=0.234 n=9+10) puffs_flate_decode_100k/clang 205MB/s ± 1% 198MB/s ± 0% -3.06% (p=0.000 n=9+10) puffs_zlib_decode_10k/clang 165MB/s ± 1% 163MB/s ± 0% -1.12% (p=0.000 n=9+9) puffs_zlib_decode_100k/clang 189MB/s ± 0% 182MB/s ± 0% -3.42% (p=0.000 n=9+9) puffs_adler32_10k/gcc 3.26GB/s ± 0% 3.26GB/s ± 0% ~ (p=0.065 n=9+10) puffs_adler32_100k/gcc 3.27GB/s ± 0% 3.27GB/s ± 0% ~ (p=0.173 n=8+10) puffs_flate_decode_1k/gcc 111MB/s ± 0% 111MB/s ± 1% ~ (p=0.971 n=10+10) puffs_flate_decode_10k/gcc 149MB/s ± 0% 142MB/s ± 0% -4.67% (p=0.000 n=9+10) puffs_flate_decode_100k/gcc 160MB/s ± 0% 153MB/s ± 0% -4.46% (p=0.000 n=9+9) puffs_zlib_decode_10k/gcc 128MB/s ± 0% 142MB/s ± 0% +11.21% (p=0.000 n=9+9) puffs_zlib_decode_100k/gcc 137MB/s ± 0% 149MB/s ± 0% +8.47% (p=0.000 n=8+8)
This commit is contained in:
1 parent
5520340d7c
commit
bf50d268ae
2 files changed
+13
-37
No files matched your search
+10
-23
@@ -2298,6 +2298,13 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
||||
v_hlen -= v_n_copied;
|
||||
v_hdist = ((v_hdist + v_n_copied) & 32767);
|
||||
if (v_hdist == 0) {
|
||||
if (v_hlen > 0) {
|
||||
puffs_base__writer1__copy_from_slice32(
|
||||
&b_wptr_dst, b_wend_dst,
|
||||
((puffs_base__slice_u8){
|
||||
.ptr = self->private_impl.f_history, .len = 32768}),
|
||||
v_hlen);
|
||||
}
|
||||
goto label_1_break;
|
||||
}
|
||||
}
|
||||
@@ -2305,26 +2312,6 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
}
|
||||
label_1_break:;
|
||||
if (v_hlen > 0) {
|
||||
while (true) {
|
||||
v_n_copied = puffs_base__writer1__copy_from_slice32(
|
||||
&b_wptr_dst, b_wend_dst,
|
||||
puffs_base__slice_u8__subslice_i(
|
||||
((puffs_base__slice_u8){
|
||||
.ptr = self->private_impl.f_history, .len = 32768}),
|
||||
v_hdist),
|
||||
v_hlen);
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
goto label_2_break;
|
||||
}
|
||||
v_hlen -= v_n_copied;
|
||||
v_hdist = ((v_hdist + (v_n_copied & 32767)) & 32767);
|
||||
status = PUFFS_FLATE__SUSPENSION_SHORT_WRITE;
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||
}
|
||||
label_2_break:;
|
||||
}
|
||||
if (v_length == 0) {
|
||||
goto label_0_continue;
|
||||
}
|
||||
@@ -2332,14 +2319,14 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
||||
puffs_base__writer1__copy_from_history32(
|
||||
&b_wptr_dst, a_dst.private_impl.mark, b_wend_dst, v_distance,
|
||||
v_length);
|
||||
goto label_3_break;
|
||||
goto label_2_break;
|
||||
}
|
||||
label_3_break:;
|
||||
label_2_break:;
|
||||
}
|
||||
label_0_break:;
|
||||
while (v_n_bits >= 8) {
|
||||
v_n_bits -= 8;
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
if (b_rptr_src == b_rstart_src) {
|
||||
status = PUFFS_FLATE__ERROR_INVALID_I_O_OPERATION;
|
||||
goto exit;
|
||||
|
||||
@@ -292,6 +292,9 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
hdist = (hdist ~+ n_copied) & 0x7FFF
|
||||
if hdist == 0 {
|
||||
// Wrap around the this.history ringbuffer.
|
||||
if hlen > 0 {
|
||||
in.dst.copy_from_slice32(s:this.history[:], length:hlen)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -304,20 +307,6 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
// suspension can change the state of this and its fields.
|
||||
assert false
|
||||
}
|
||||
// Copy from the start of this.history, if we wrapped around.
|
||||
if hlen > 0 {
|
||||
while true {
|
||||
n_copied = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
||||
if hlen <= n_copied {
|
||||
hlen = 0
|
||||
break
|
||||
}
|
||||
hlen -= n_copied
|
||||
hdist = (hdist + (n_copied & 0x7FFF)) & 0x7FFF
|
||||
// TODO: "closed for writes" instead?
|
||||
return suspension "short write"
|
||||
}
|
||||
}
|
||||
|
||||
if length == 0 {
|
||||
// No need to copy from in.dst.
|
||||
|
||||
Reference in new issue
Block a user