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.41GB/s ± 1% 2.39GB/s ± 2% -0.88% (p=0.022 n=9+10) puffs_adler32_100k/clang 2.41GB/s ± 1% 2.39GB/s ± 2% ~ (p=0.095 n=10+9) puffs_flate_decode_1k/clang 136MB/s ± 2% 134MB/s ± 1% -0.86% (p=0.036 n=9+8) puffs_flate_decode_10k/clang 172MB/s ± 0% 175MB/s ± 0% +1.96% (p=0.000 n=8+9) puffs_flate_decode_100k/clang 206MB/s ± 0% 209MB/s ± 1% +1.38% (p=0.000 n=8+9) puffs_zlib_decode_10k/clang 160MB/s ± 1% 163MB/s ± 2% +1.73% (p=0.001 n=9+9) puffs_zlib_decode_100k/clang 189MB/s ± 1% 188MB/s ± 6% ~ (p=0.143 n=10+10) puffs_adler32_10k/gcc 3.27GB/s ± 0% 3.20GB/s ± 2% -2.03% (p=0.000 n=8+10) puffs_adler32_100k/gcc 3.27GB/s ± 0% 3.21GB/s ± 1% -1.89% (p=0.000 n=8+10) puffs_flate_decode_1k/gcc 141MB/s ± 1% 139MB/s ± 1% -1.66% (p=0.000 n=9+10) puffs_flate_decode_10k/gcc 200MB/s ± 0% 209MB/s ± 1% +4.73% (p=0.000 n=10+10) puffs_flate_decode_100k/gcc 242MB/s ± 0% 237MB/s ± 0% -2.19% (p=0.000 n=9+10) puffs_zlib_decode_10k/gcc 188MB/s ± 0% 195MB/s ± 1% +3.71% (p=0.000 n=10+10) puffs_zlib_decode_100k/gcc 225MB/s ± 0% 221MB/s ± 0% -1.84% (p=0.000 n=8+9)
This commit is contained in:
1 parent
058938006a
commit
0bc6f792fb
5 files changed
+24
-92
No files matched your search
@@ -117,6 +117,11 @@ func (g *gen) writeFuncPrototype(b *buffer, n *a.Func) error {
|
||||
func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
|
||||
k := g.funks[n.QID()]
|
||||
|
||||
// TODO: delete this. This bool should only last for one git commit, to
|
||||
// separate one conceptual code change into two diff's: one small semantic
|
||||
// diff and one large cosmetic diff.
|
||||
temporaryIndentationHack := k.cName == "puffs_flate__flate_decoder__decode_huffman_fast"
|
||||
|
||||
if err := g.writeFuncSignature(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -124,10 +129,14 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
|
||||
b.writex(k.bHeader)
|
||||
if k.suspendible && k.coroSuspPoint > 0 {
|
||||
b.writex(k.bBodyResume)
|
||||
} else if temporaryIndentationHack {
|
||||
b.writes("{\n")
|
||||
}
|
||||
b.writex(k.bBody)
|
||||
if k.suspendible && k.coroSuspPoint > 0 {
|
||||
b.writex(k.bBodySuspend)
|
||||
} else if temporaryIndentationHack {
|
||||
b.writes("}\n")
|
||||
}
|
||||
b.writex(k.bFooter)
|
||||
b.writes("}\n\n")
|
||||
|
||||
@@ -460,12 +460,10 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
b.printf(" = *%srptr_src++;\n", bPrefix)
|
||||
|
||||
} else if isInSrc(g.tm, n, t.KeyUnreadU8, 0) {
|
||||
if !n.ProvenNotToSuspend() {
|
||||
b.printf("if (%srptr_src == %srstart_src) { status = %sERROR_INVALID_I_O_OPERATION;",
|
||||
bPrefix, bPrefix, g.PKGPREFIX)
|
||||
b.writes("goto exit;")
|
||||
b.writes("}\n")
|
||||
}
|
||||
b.printf("if (%srptr_src == %srstart_src) { status = %sERROR_INVALID_I_O_OPERATION;",
|
||||
bPrefix, bPrefix, g.PKGPREFIX)
|
||||
b.writes("goto exit;")
|
||||
b.writes("}\n")
|
||||
b.printf("%srptr_src--;\n", bPrefix)
|
||||
|
||||
} else if isInSrc(g.tm, n, t.KeyReadU16BE, 0) {
|
||||
|
||||
+1
-62
@@ -236,22 +236,6 @@ typedef struct {
|
||||
uint8_t v_rep_symbol;
|
||||
uint32_t v_rep_count;
|
||||
} c_init_dynamic_huffman[1];
|
||||
struct {
|
||||
uint32_t coro_susp_point;
|
||||
uint32_t v_bits;
|
||||
uint32_t v_n_bits;
|
||||
uint32_t v_table_entry;
|
||||
uint32_t v_table_entry_n_bits;
|
||||
uint32_t v_lmask;
|
||||
uint32_t v_dmask;
|
||||
uint32_t v_redir_top;
|
||||
uint32_t v_redir_mask;
|
||||
uint32_t v_length;
|
||||
uint32_t v_distance;
|
||||
uint32_t v_n_copied;
|
||||
uint32_t v_hlen;
|
||||
uint32_t v_hdist;
|
||||
} c_decode_huffman_fast[1];
|
||||
struct {
|
||||
uint32_t coro_susp_point;
|
||||
uint32_t v_bits;
|
||||
@@ -2029,27 +2013,7 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
||||
b_rend_src = b_rptr_src + len;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point =
|
||||
self->private_impl.c_decode_huffman_fast[0].coro_susp_point;
|
||||
if (coro_susp_point) {
|
||||
v_bits = self->private_impl.c_decode_huffman_fast[0].v_bits;
|
||||
v_n_bits = self->private_impl.c_decode_huffman_fast[0].v_n_bits;
|
||||
v_table_entry = self->private_impl.c_decode_huffman_fast[0].v_table_entry;
|
||||
v_table_entry_n_bits =
|
||||
self->private_impl.c_decode_huffman_fast[0].v_table_entry_n_bits;
|
||||
v_lmask = self->private_impl.c_decode_huffman_fast[0].v_lmask;
|
||||
v_dmask = self->private_impl.c_decode_huffman_fast[0].v_dmask;
|
||||
v_redir_top = self->private_impl.c_decode_huffman_fast[0].v_redir_top;
|
||||
v_redir_mask = self->private_impl.c_decode_huffman_fast[0].v_redir_mask;
|
||||
v_length = self->private_impl.c_decode_huffman_fast[0].v_length;
|
||||
v_distance = self->private_impl.c_decode_huffman_fast[0].v_distance;
|
||||
v_n_copied = self->private_impl.c_decode_huffman_fast[0].v_n_copied;
|
||||
v_hlen = self->private_impl.c_decode_huffman_fast[0].v_hlen;
|
||||
v_hdist = self->private_impl.c_decode_huffman_fast[0].v_hdist;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
{
|
||||
if (self->private_impl.f_n_bits >= 8) {
|
||||
status = PUFFS_FLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS;
|
||||
goto exit;
|
||||
@@ -2306,7 +2270,6 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
||||
label_0_break:;
|
||||
while (v_n_bits >= 8) {
|
||||
v_n_bits -= 8;
|
||||
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
if (b_rptr_src == b_rstart_src) {
|
||||
status = PUFFS_FLATE__ERROR_INVALID_I_O_OPERATION;
|
||||
goto exit;
|
||||
@@ -2319,31 +2282,7 @@ static puffs_flate__status puffs_flate__flate_decoder__decode_huffman_fast(
|
||||
status = PUFFS_FLATE__ERROR_INTERNAL_ERROR_INCONSISTENT_N_BITS;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.c_decode_huffman_fast[0].coro_susp_point = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.c_decode_huffman_fast[0].coro_susp_point = coro_susp_point;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_bits = v_bits;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_n_bits = v_n_bits;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_table_entry = v_table_entry;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_table_entry_n_bits =
|
||||
v_table_entry_n_bits;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_lmask = v_lmask;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_dmask = v_dmask;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_redir_top = v_redir_top;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_redir_mask = v_redir_mask;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_length = v_length;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_distance = v_distance;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_n_copied = v_n_copied;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_hlen = v_hlen;
|
||||
self->private_impl.c_decode_huffman_fast[0].v_hdist = v_hdist;
|
||||
|
||||
exit:
|
||||
if (a_dst.buf) {
|
||||
size_t n = b_wptr_dst - (a_dst.buf->ptr + a_dst.buf->wi);
|
||||
|
||||
@@ -236,22 +236,6 @@ typedef struct {
|
||||
uint8_t v_rep_symbol;
|
||||
uint32_t v_rep_count;
|
||||
} c_init_dynamic_huffman[1];
|
||||
struct {
|
||||
uint32_t coro_susp_point;
|
||||
uint32_t v_bits;
|
||||
uint32_t v_n_bits;
|
||||
uint32_t v_table_entry;
|
||||
uint32_t v_table_entry_n_bits;
|
||||
uint32_t v_lmask;
|
||||
uint32_t v_dmask;
|
||||
uint32_t v_redir_top;
|
||||
uint32_t v_redir_mask;
|
||||
uint32_t v_length;
|
||||
uint32_t v_distance;
|
||||
uint32_t v_n_copied;
|
||||
uint32_t v_hlen;
|
||||
uint32_t v_hdist;
|
||||
} c_decode_huffman_fast[1];
|
||||
struct {
|
||||
uint32_t coro_susp_point;
|
||||
uint32_t v_bits;
|
||||
|
||||
+10
-8
@@ -1187,19 +1187,21 @@ func (q *checker) bcheckIOMethods(n *a.Expr, depth uint32) error {
|
||||
if receiver.ID0().Key() != t.KeyDot {
|
||||
return nil
|
||||
}
|
||||
receiver, method := receiver.LHS().Expr(), receiver.ID1().Key()
|
||||
|
||||
// TODO: check that receiver's type is actually a reader1 or writer1.
|
||||
|
||||
advance := (*big.Int)(nil)
|
||||
if key := receiver.ID1().Key(); key == t.KeyUnreadU8 {
|
||||
// TODO: call SetProvenNotToSuspend, since unread_u8 can never suspend,
|
||||
// only succeed or fail.
|
||||
} else if key < t.Key(len(ioMethodAdvances)) {
|
||||
advance = ioMethodAdvances[key]
|
||||
if method == t.KeyUnreadU8 {
|
||||
// unread_u8 can never suspend, only succeed or fail.
|
||||
n.SetProvenNotToSuspend()
|
||||
return nil
|
||||
} else if method < t.Key(len(ioMethodAdvances)) {
|
||||
advance = ioMethodAdvances[method]
|
||||
}
|
||||
if advance == nil {
|
||||
return nil
|
||||
}
|
||||
receiver = receiver.LHS().Expr()
|
||||
|
||||
// TODO: check that receiver's type is actually a reader1 or writer1.
|
||||
|
||||
return q.facts.update(func(x *a.Expr) (*a.Expr, error) {
|
||||
op := x.ID0().Key()
|
||||
|
||||
Reference in new issue
Block a user