Don't suspend for read_u8 if data is available.

It's not obvious why the benchmarks get worse when the code looks
better, but the long term goal is for all of decode_huffman_fast to not
suspend, and this is one step along that path.

name                           old speed      new speed      delta

puffs_adler32_10k/clang        2.40GB/s ± 1%  2.40GB/s ± 1%     ~     (p=0.841 n=5+5)
puffs_adler32_100k/clang       2.40GB/s ± 1%  2.39GB/s ± 2%     ~     (p=0.421 n=5+5)
puffs_flate_decode_1k/clang     131MB/s ± 1%   128MB/s ± 0%   -2.51%  (p=0.008 n=5+5)
puffs_flate_decode_10k/clang    171MB/s ± 1%   167MB/s ± 2%   -2.86%  (p=0.008 n=5+5)
puffs_flate_decode_100k/clang   202MB/s ± 0%   193MB/s ± 2%   -4.64%  (p=0.016 n=4+5)
puffs_zlib_decode_10k/clang     159MB/s ± 1%   157MB/s ± 0%   -1.65%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/clang    185MB/s ± 1%   180MB/s ± 1%   -3.11%  (p=0.008 n=5+5)

puffs_adler32_10k/gcc          3.26GB/s ± 0%  3.26GB/s ± 0%     ~     (p=0.421 n=5+5)
puffs_adler32_100k/gcc         3.27GB/s ± 0%  3.26GB/s ± 0%     ~     (p=0.151 n=5+5)
puffs_flate_decode_1k/gcc       132MB/s ± 0%   129MB/s ± 0%   -2.29%  (p=0.008 n=5+5)
puffs_flate_decode_10k/gcc      170MB/s ± 0%   164MB/s ± 0%   -3.13%  (p=0.008 n=5+5)
puffs_flate_decode_100k/gcc     207MB/s ± 0%   185MB/s ± 0%  -10.45%  (p=0.016 n=5+4)
puffs_zlib_decode_10k/gcc       162MB/s ± 0%   157MB/s ± 0%   -2.95%  (p=0.008 n=5+5)
puffs_zlib_decode_100k/gcc      194MB/s ± 0%   175MB/s ± 0%   -9.78%  (p=0.016 n=5+4)
This commit is contained in:
Nigel Tao committed 2017-11-05 08:03:21 +11:00
1 parent cf61ca11c3
commit 55e0bc513b
4 files changed
+107 -54

No files matched your search

+28 -25
View File
@@ -87,15 +87,16 @@ var kindStrings = [...]string{
type Flags uint32
const (
FlagsImpure = Flags(0x00000001)
FlagsSuspendible = Flags(0x00000002)
FlagsCallImpure = Flags(0x00000004)
FlagsCallSuspendible = Flags(0x00000008)
FlagsPublic = Flags(0x00000010)
FlagsTypeChecked = Flags(0x00000020)
FlagsHasBreak = Flags(0x00000040)
FlagsHasContinue = Flags(0x00000080)
FlagsGlobalIdent = Flags(0x00000100)
FlagsImpure = Flags(0x00000001)
FlagsSuspendible = Flags(0x00000002)
FlagsCallImpure = Flags(0x00000004)
FlagsCallSuspendible = Flags(0x00000008)
FlagsPublic = Flags(0x00000010)
FlagsTypeChecked = Flags(0x00000020)
FlagsHasBreak = Flags(0x00000040)
FlagsHasContinue = Flags(0x00000080)
FlagsGlobalIdent = Flags(0x00000100)
FlagsProvenNotToSuspend = Flags(0x00000200)
)
type Node struct {
@@ -244,25 +245,27 @@ const MaxExprDepth = 255
// and ID1 is the message.
type Expr Node
func (n *Expr) Node() *Node { return (*Node)(n) }
func (n *Expr) Pure() bool { return n.flags&FlagsImpure == 0 }
func (n *Expr) Impure() bool { return n.flags&FlagsImpure != 0 }
func (n *Expr) Suspendible() bool { return n.flags&FlagsSuspendible != 0 }
func (n *Expr) CallImpure() bool { return n.flags&FlagsCallImpure != 0 }
func (n *Expr) CallSuspendible() bool { return n.flags&FlagsCallSuspendible != 0 }
func (n *Expr) GlobalIdent() bool { return n.flags&FlagsGlobalIdent != 0 }
func (n *Expr) ConstValue() *big.Int { return n.constValue }
func (n *Expr) MType() *TypeExpr { return n.mType }
func (n *Expr) ID0() t.ID { return n.id0 }
func (n *Expr) ID1() t.ID { return n.id1 }
func (n *Expr) LHS() *Node { return n.lhs }
func (n *Expr) MHS() *Node { return n.mhs }
func (n *Expr) RHS() *Node { return n.rhs }
func (n *Expr) Args() []*Node { return n.list0 }
func (n *Expr) Node() *Node { return (*Node)(n) }
func (n *Expr) Pure() bool { return n.flags&FlagsImpure == 0 }
func (n *Expr) Impure() bool { return n.flags&FlagsImpure != 0 }
func (n *Expr) Suspendible() bool { return n.flags&FlagsSuspendible != 0 }
func (n *Expr) CallImpure() bool { return n.flags&FlagsCallImpure != 0 }
func (n *Expr) CallSuspendible() bool { return n.flags&FlagsCallSuspendible != 0 }
func (n *Expr) GlobalIdent() bool { return n.flags&FlagsGlobalIdent != 0 }
func (n *Expr) ProvenNotToSuspend() bool { return n.flags&FlagsProvenNotToSuspend != 0 }
func (n *Expr) ConstValue() *big.Int { return n.constValue }
func (n *Expr) MType() *TypeExpr { return n.mType }
func (n *Expr) ID0() t.ID { return n.id0 }
func (n *Expr) ID1() t.ID { return n.id1 }
func (n *Expr) LHS() *Node { return n.lhs }
func (n *Expr) MHS() *Node { return n.mhs }
func (n *Expr) RHS() *Node { return n.rhs }
func (n *Expr) Args() []*Node { return n.list0 }
func (n *Expr) SetConstValue(x *big.Int) { n.constValue = x }
func (n *Expr) SetMType(x *TypeExpr) { n.mType = x }
func (n *Expr) SetGlobalIdent() { n.flags |= FlagsGlobalIdent }
func (n *Expr) SetMType(x *TypeExpr) { n.mType = x }
func (n *Expr) SetProvenNotToSuspend() { n.flags |= FlagsProvenNotToSuspend }
func NewExpr(flags Flags, operator t.ID, nameLiteralSelector t.ID, lhs *Node, mhs *Node, rhs *Node, args []*Node) *Expr {
if lhs != nil {