mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 00:47:28 +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
@@ -4541,7 +4541,7 @@ struct wuffs_deflate__decoder__struct {
|
||||
|
||||
struct {
|
||||
uint32_t f_huffs[2][1024];
|
||||
uint8_t f_history[32768];
|
||||
uint8_t f_history[33025];
|
||||
uint8_t f_code_lengths[320];
|
||||
|
||||
struct {
|
||||
@@ -11617,18 +11617,24 @@ wuffs_deflate__decoder__add_history(wuffs_deflate__decoder* self,
|
||||
if (((uint64_t)(v_s.len)) >= 32768) {
|
||||
v_s = wuffs_base__slice_u8__suffix(v_s, 32768);
|
||||
wuffs_base__slice_u8__copy_from_slice(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768), v_s);
|
||||
wuffs_base__slice_u8__subslice_j(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 33025),
|
||||
32768),
|
||||
v_s);
|
||||
self->private_impl.f_history_index = 32768;
|
||||
} else {
|
||||
v_n_copied = wuffs_base__slice_u8__copy_from_slice(
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768),
|
||||
(self->private_impl.f_history_index & 32767)),
|
||||
wuffs_base__slice_u8__subslice_ij(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 33025),
|
||||
(self->private_impl.f_history_index & 32767), 32768),
|
||||
v_s);
|
||||
if (v_n_copied < ((uint64_t)(v_s.len))) {
|
||||
v_s = wuffs_base__slice_u8__subslice_i(v_s, v_n_copied);
|
||||
v_n_copied = wuffs_base__slice_u8__copy_from_slice(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768), v_s);
|
||||
wuffs_base__slice_u8__subslice_j(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 33025),
|
||||
32768),
|
||||
v_s);
|
||||
self->private_impl.f_history_index =
|
||||
(((uint32_t)((v_n_copied & 32767))) + 32768);
|
||||
} else {
|
||||
@@ -11641,6 +11647,11 @@ wuffs_deflate__decoder__add_history(wuffs_deflate__decoder* self,
|
||||
((uint32_t)((v_n_copied & 32767))) + v_already_full);
|
||||
}
|
||||
}
|
||||
wuffs_base__slice_u8__copy_from_slice(
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 33025),
|
||||
32768),
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 33025));
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
@@ -12649,7 +12660,6 @@ wuffs_deflate__decoder__decode_huffman_fast(wuffs_deflate__decoder* self,
|
||||
uint32_t v_redir_mask = 0;
|
||||
uint32_t v_length = 0;
|
||||
uint32_t v_dist_minus_1 = 0;
|
||||
uint32_t v_n_copied = 0;
|
||||
uint32_t v_hlen = 0;
|
||||
uint32_t v_hdist = 0;
|
||||
|
||||
@@ -12858,7 +12868,6 @@ label__loop__continue:;
|
||||
32767);
|
||||
v_bits >>= v_table_entry_n_bits;
|
||||
v_n_bits -= v_table_entry_n_bits;
|
||||
v_n_copied = 0;
|
||||
while (true) {
|
||||
if (((uint64_t)((v_dist_minus_1 + 1))) >
|
||||
((uint64_t)(iop_a_dst - io0_a_dst))) {
|
||||
@@ -12877,23 +12886,11 @@ label__loop__continue:;
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
while (true) {
|
||||
v_n_copied = wuffs_base__io_writer__copy_n32_from_slice(
|
||||
&iop_a_dst, io2_a_dst, v_hlen,
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history,
|
||||
32768),
|
||||
(v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
goto label__0__break;
|
||||
}
|
||||
v_hlen -= v_n_copied;
|
||||
wuffs_base__io_writer__copy_n32_from_slice(
|
||||
&iop_a_dst, io2_a_dst, v_hlen,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 32768));
|
||||
goto label__0__break;
|
||||
}
|
||||
label__0__break:;
|
||||
wuffs_base__io_writer__copy_n32_from_slice(
|
||||
&iop_a_dst, io2_a_dst, v_hlen,
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history, 33025),
|
||||
(v_hdist & 32767)));
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -12906,9 +12903,9 @@ label__loop__continue:;
|
||||
}
|
||||
wuffs_base__io_writer__copy_n32_from_history_fast(
|
||||
&iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1));
|
||||
goto label__1__break;
|
||||
goto label__0__break;
|
||||
}
|
||||
label__1__break:;
|
||||
label__0__break:;
|
||||
}
|
||||
label__loop__break:;
|
||||
while (v_n_bits >= 8) {
|
||||
@@ -13257,10 +13254,10 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
|
||||
while (true) {
|
||||
v_n_copied = wuffs_base__io_writer__copy_n32_from_slice(
|
||||
&iop_a_dst, io2_a_dst, v_hlen,
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
wuffs_base__slice_u8__subslice_ij(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history,
|
||||
32768),
|
||||
(v_hdist & 32767)));
|
||||
33025),
|
||||
(v_hdist & 32767), 32768));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
goto label__4__break;
|
||||
@@ -13281,10 +13278,10 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
|
||||
while (true) {
|
||||
v_n_copied = wuffs_base__io_writer__copy_n32_from_slice(
|
||||
&iop_a_dst, io2_a_dst, v_hlen,
|
||||
wuffs_base__slice_u8__subslice_i(
|
||||
wuffs_base__slice_u8__subslice_ij(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_history,
|
||||
32768),
|
||||
(v_hdist & 32767)));
|
||||
33025),
|
||||
(v_hdist & 32767), 32768));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
goto label__5__break;
|
||||
|
||||
Reference in new issue
Block a user