Remove some suspensions from decode_huffman_fast.

name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.46GB/s ± 0%  2.45GB/s ± 2%     ~     (p=0.352 n=9+9)
puffs_adler32_100k/clang       2.46GB/s ± 0%  2.46GB/s ± 0%     ~     (p=0.673 n=9+8)
puffs_flate_decode_1k/clang     124MB/s ± 0%   125MB/s ± 0%   +0.39%  (p=0.000 n=8+9)
puffs_flate_decode_10k/clang    165MB/s ± 0%   168MB/s ± 0%   +1.81%  (p=0.000 n=8+10)
puffs_flate_decode_100k/clang   195MB/s ± 0%   193MB/s ± 0%   -1.30%  (p=0.000 n=9+9)
puffs_zlib_decode_10k/clang     154MB/s ± 1%   157MB/s ± 0%   +1.96%  (p=0.000 n=9+9)
puffs_zlib_decode_100k/clang    181MB/s ± 0%   179MB/s ± 0%   -1.19%  (p=0.000 n=10+8)

puffs_adler32_10k/gcc          3.26GB/s ± 0%  3.26GB/s ± 0%     ~     (p=0.549 n=9+10)
puffs_adler32_100k/gcc         3.27GB/s ± 0%  3.27GB/s ± 0%     ~     (p=0.450 n=9+9)
puffs_flate_decode_1k/gcc       112MB/s ± 0%   122MB/s ± 0%   +9.10%  (p=0.000 n=10+10)
puffs_flate_decode_10k/gcc      155MB/s ± 0%   176MB/s ± 0%  +13.63%  (p=0.000 n=10+10)
puffs_flate_decode_100k/gcc     176MB/s ± 0%   199MB/s ± 0%  +12.74%  (p=0.000 n=9+10)
puffs_zlib_decode_10k/gcc       137MB/s ± 0%   168MB/s ± 0%  +22.54%  (p=0.000 n=9+10)
puffs_zlib_decode_100k/gcc      158MB/s ± 0%   187MB/s ± 0%  +18.87%  (p=0.000 n=9+9)
This commit is contained in:
Nigel Tao committed 2017-11-05 22:40:18 +11:00
1 parent 934705a6e1
commit e7c14dfe63
2 files changed
+24 -26

No files matched your search

+12 -19
View File
@@ -2229,19 +2229,20 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
PUFFS_FLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_HUFFMAN_DECODER_STATE;
goto exit;
}
v_distance = ((v_table_entry >> 8) & 32767);
v_table_entry_n_bits = ((v_table_entry >> 4) & 15);
while (v_n_bits < v_table_entry_n_bits) {
if (v_n_bits < 15) {
{
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
if (PUFFS_BASE__UNLIKELY(b_rptr_src == b_rend_src)) {
goto short_read_src;
}
uint8_t t_10 = *b_rptr_src++;
v_bits |= (((uint32_t)(t_10)) << v_n_bits);
}
v_n_bits += 8;
{
uint8_t t_11 = *b_rptr_src++;
v_bits |= (((uint32_t)(t_11)) << v_n_bits);
}
v_n_bits += 8;
}
v_distance = ((v_table_entry >> 8) & 32767);
v_table_entry_n_bits = ((v_table_entry >> 4) & 15);
v_distance =
((v_distance + ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1))) &
32767);
@@ -2301,7 +2302,7 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
}
}
status = PUFFS_FLATE__SUSPENSION_SHORT_WRITE;
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
}
label_1_break:;
if (v_hlen > 0) {
@@ -2320,7 +2321,7 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
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(5);
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
}
label_2_break:;
}
@@ -2337,14 +2338,14 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
}
v_length -= v_n_copied;
status = PUFFS_FLATE__SUSPENSION_SHORT_WRITE;
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
}
label_3_break:;
}
label_0_break:;
while (v_n_bits >= 8) {
v_n_bits -= 8;
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
if (b_rptr_src == b_rstart_src) {
status = PUFFS_FLATE__ERROR_INVALID_I_O_OPERATION;
goto exit;
@@ -2409,14 +2410,6 @@ exit:
}
return status;
short_read_src:
if (a_src.buf && a_src.buf->closed && !a_src.private_impl.limit.ptr_to_len) {
status = PUFFS_FLATE__ERROR_UNEXPECTED_EOF;
goto exit;
}
status = PUFFS_FLATE__SUSPENSION_SHORT_READ;
goto suspend;
}
static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_slow(
+12 -7
View File
@@ -235,16 +235,21 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
return error "internal error: inconsistent Huffman decoder state"
}
// Ensure that we have at least 15 bits of input.
if n_bits < 15 {
assert n_bits >= 0 // TODO: this shouldn't be necessary.
bits |= (in.src.read_u8?() as u32) << n_bits
n_bits += 8
bits |= (in.src.read_u8?() as u32) << n_bits
n_bits += 8
assert n_bits >= 15
}
// Once again, redundant but explicit assertions.
assert n_bits >= 15
// distance = base number + extra bits.
var distance u32[..0x7FFF] = (table_entry >> 8) & 0x7FFF
table_entry_n_bits = (table_entry >> 4) & 0x0F
while n_bits < table_entry_n_bits,
post n_bits >= table_entry_n_bits,
{
assert n_bits < 15 via "a < b: a < c; c <= b"(c:table_entry_n_bits)
bits |= (in.src.read_u8?() as u32) << n_bits
n_bits += 8
}
distance = (distance + bits.low_bits(n:table_entry_n_bits)) & 0x7FFF
bits >>= table_entry_n_bits
n_bits -= table_entry_n_bits