mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Add etc_copy_u32_from_history_8_byte_chunks_fast
On a mid-range x86_64 laptop:
----
$ ls -lh linux-5.11.3.tar.gz | awk '{print $5 " " $9}'
178M linux-5.11.3.tar.gz
$ # Debian's /usr/bin/zcat
$ time /usr/bin/zcat < linux-5.11.3.tar.gz > /dev/null
real 0m8.423s
$ # Wuffs; before
$ time gen/bin/example-zcat < linux-5.11.3.tar.gz > /dev/null
real 0m4.054s
$ # Wuffs; after
$ time gen/bin/example-zcat < linux-5.11.3.tar.gz > /dev/null
real 0m2.651s
----
Wuffs benchmarks:
wuffs_deflate_decode_1k_full_init/clang9 95.6MB/s ± 0% 98.1MB/s ± 1% +2.62% (p=0.008 n=5+5)
wuffs_deflate_decode_1k_part_init/clang9 109MB/s ± 0% 112MB/s ± 0% +3.31% (p=0.008 n=5+5)
wuffs_deflate_decode_10k_full_init/clang9 162MB/s ± 0% 201MB/s ± 0% +24.32% (p=0.008 n=5+5)
wuffs_deflate_decode_10k_part_init/clang9 165MB/s ± 0% 206MB/s ± 0% +25.16% (p=0.008 n=5+5)
wuffs_deflate_decode_100k_just_one_read/clang9 170MB/s ± 0% 253MB/s ± 0% +48.63% (p=0.008 n=5+5)
wuffs_deflate_decode_100k_many_big_reads/clang9 147MB/s ± 0% 160MB/s ± 0% +8.77% (p=0.016 n=4+5)
wuffs_deflate_decode_1k_full_init/gcc10 92.1MB/s ± 0% 91.7MB/s ± 0% -0.44% (p=0.016 n=5+5)
wuffs_deflate_decode_1k_part_init/gcc10 107MB/s ± 0% 104MB/s ± 0% -3.35% (p=0.008 n=5+5)
wuffs_deflate_decode_10k_full_init/gcc10 149MB/s ± 0% 195MB/s ± 0% +30.68% (p=0.008 n=5+5)
wuffs_deflate_decode_10k_part_init/gcc10 152MB/s ± 1% 199MB/s ± 1% +31.23% (p=0.008 n=5+5)
wuffs_deflate_decode_100k_just_one_read/gcc10 213MB/s ± 0% 256MB/s ± 0% +20.42% (p=0.008 n=5+5)
wuffs_deflate_decode_100k_many_big_reads/gcc10 177MB/s ± 0% 177MB/s ± 1% ~ (p=0.595 n=5+5)
mimic_deflate_decode_1k 128MB/s ± 0% 128MB/s ± 0% +0.42% (p=0.016 n=5+4)
mimic_deflate_decode_10k 143MB/s ± 0% 143MB/s ± 0% ~ (p=0.310 n=5+5)
mimic_deflate_decode_100k_just_one_read 176MB/s ± 0% 176MB/s ± 0% -0.24% (p=0.008 n=5+5)
mimic_deflate_decode_100k_many_big_reads 135MB/s ± 0% 135MB/s ± 0% +0.12% (p=0.016 n=5+5)
----
wuffs_gzip_decode_10k/clang9 166MB/s ± 0% 198MB/s ± 1% +19.66% (p=0.008 n=5+5)
wuffs_gzip_decode_100k/clang9 178MB/s ± 0% 241MB/s ± 0% +35.41% (p=0.008 n=5+5)
wuffs_gzip_decode_10k/gcc10 172MB/s ± 0% 199MB/s ± 0% +15.67% (p=0.008 n=5+5)
wuffs_gzip_decode_100k/gcc10 198MB/s ± 0% 258MB/s ± 0% +29.95% (p=0.008 n=5+5)
mimic_gzip_decode_10k 121MB/s ± 0% 121MB/s ± 0% ~ (p=0.421 n=5+5)
mimic_gzip_decode_100k 144MB/s ± 0% 144MB/s ± 0% ~ (p=0.548 n=5+5)
----
wuffs_zlib_decode_10k/clang9 154MB/s ± 0% 199MB/s ± 0% +28.89% (p=0.016 n=4+5)
wuffs_zlib_decode_100k/clang9 186MB/s ± 1% 234MB/s ± 1% +25.58% (p=0.008 n=5+5)
wuffs_zlib_decode_10k/gcc10 156MB/s ± 0% 202MB/s ± 0% +30.01% (p=0.008 n=5+5)
wuffs_zlib_decode_100k/gcc10 198MB/s ± 0% 262MB/s ± 0% +32.21% (p=0.008 n=5+5)
mimic_zlib_decode_10k 133MB/s ± 0% 133MB/s ± 0% ~ (p=1.000 n=5+5)
mimic_zlib_decode_100k 160MB/s ± 0% 160MB/s ± 0% ~ (p=0.095 n=5+5)
----
wuffs_png_decode_image_19k_8bpp/clang9 115MB/s ± 0% 131MB/s ± 0% +14.45% (p=0.008 n=5+5)
wuffs_png_decode_image_40k_24bpp/clang9 153MB/s ± 0% 153MB/s ± 0% -0.51% (p=0.008 n=5+5)
wuffs_png_decode_image_77k_8bpp/clang9 415MB/s ± 0% 474MB/s ± 0% +14.37% (p=0.016 n=4+5)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/clang9 345MB/s ± 1% 371MB/s ± 0% +7.62% (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_verify_checksum/clang9 335MB/s ± 0% 359MB/s ± 0% +7.06% (p=0.016 n=4+5)
wuffs_png_decode_image_4002k_24bpp/clang9 153MB/s ± 0% 156MB/s ± 0% +2.37% (p=0.008 n=5+5)
wuffs_png_decode_image_19k_8bpp/gcc10 123MB/s ± 0% 135MB/s ± 1% +9.38% (p=0.008 n=5+5)
wuffs_png_decode_image_40k_24bpp/gcc10 159MB/s ± 1% 163MB/s ± 0% +2.60% (p=0.016 n=5+4)
wuffs_png_decode_image_77k_8bpp/gcc10 452MB/s ± 0% 479MB/s ± 0% +6.00% (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/gcc10 353MB/s ± 0% 387MB/s ± 0% +9.42% (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_verify_checksum/gcc10 341MB/s ± 0% 372MB/s ± 0% +9.07% (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/gcc10 161MB/s ± 0% 164MB/s ± 0% +1.86% (p=0.016 n=4+5)
mimic_png_decode_image_19k_8bpp 58.1MB/s ± 0% 58.2MB/s ± 0% +0.22% (p=0.008 n=5+5)
mimic_png_decode_image_40k_24bpp 73.2MB/s ± 0% 73.2MB/s ± 0% ~ (p=0.341 n=5+5)
mimic_png_decode_image_77k_8bpp 177MB/s ± 0% 177MB/s ± 0% ~ (p=0.095 n=5+5)
mimic_png_decode_image_552k_32bpp_ignore_checksum skipped
mimic_png_decode_image_552k_32bpp_verify_checksum 147MB/s ± 0% 146MB/s ± 0% ~ (p=0.056 n=5+5)
mimic_png_decode_image_4002k_24bpp 104MB/s ± 0% 104MB/s ± 0% ~ (p=0.841 n=4+5)
This commit is contained in:
1 parent
79c7ba0ae9
commit
b58a961acb
8 files changed
+186
-49
No files matched your search
@@ -538,10 +538,17 @@ var funcsOther = [...]string{
|
||||
// TODO: this should have explicit pre-conditions:
|
||||
// - up_to <= this.length()
|
||||
// - distance > 0
|
||||
// - distance <= this.since_mark().length()
|
||||
// - distance <= this.history_length()
|
||||
// For now, that's all implicitly checked (i.e. hard coded).
|
||||
"io_writer.limited_copy_u32_from_history_fast!(up_to: u32, distance: u32) u32",
|
||||
|
||||
// TODO: this should have explicit pre-conditions:
|
||||
// - (up_to + 8) <= this.length()
|
||||
// - distance > 0
|
||||
// - distance <= this.history_length()
|
||||
// For now, that's all implicitly checked (i.e. hard coded).
|
||||
"io_writer.limited_copy_u32_from_history_8_byte_chunks_fast!(up_to: u32, distance: u32) u32",
|
||||
|
||||
// ---- token_writer
|
||||
|
||||
"token_writer.write_simple_token_fast!(" +
|
||||
|
||||
+32
-8
@@ -1167,8 +1167,13 @@ func (q *checker) bcheckExprCallSpecialCases(n *a.Expr, depth uint32) (bounds, e
|
||||
return bounds{}, err
|
||||
}
|
||||
|
||||
} else if method == t.IDLimitedCopyU32FromHistory8ByteChunksFast {
|
||||
if err := q.canLimitedCopyU32FromHistoryFast(recv, n.Args(), eight); err != nil {
|
||||
return bounds{}, err
|
||||
}
|
||||
|
||||
} else if method == t.IDLimitedCopyU32FromHistoryFast {
|
||||
if err := q.canLimitedCopyU32FromHistoryFast(recv, n.Args()); err != nil {
|
||||
if err := q.canLimitedCopyU32FromHistoryFast(recv, n.Args(), nil); err != nil {
|
||||
return bounds{}, err
|
||||
}
|
||||
|
||||
@@ -1281,11 +1286,13 @@ func (q *checker) canUndoByte(recv *a.Expr) error {
|
||||
return fmt.Errorf("check: could not prove %s.can_undo_byte()", recv.Str(q.tm))
|
||||
}
|
||||
|
||||
func (q *checker) canLimitedCopyU32FromHistoryFast(recv *a.Expr, args []*a.Node) error {
|
||||
func (q *checker) canLimitedCopyU32FromHistoryFast(recv *a.Expr, args []*a.Node, adj *big.Int) error {
|
||||
// As per cgen's io-private.h, there are three pre-conditions:
|
||||
// - upTo <= this.length()
|
||||
// - (upTo + adj) <= this.length()
|
||||
// - distance > 0
|
||||
// - distance <= this.history_length()
|
||||
//
|
||||
// adj may be nil, in which case (upTo + adj) is just upTo.
|
||||
|
||||
if len(args) != 2 {
|
||||
return fmt.Errorf("check: internal error: inconsistent limited_copy_u32_from_history_fast arguments")
|
||||
@@ -1301,15 +1308,26 @@ check0:
|
||||
continue
|
||||
}
|
||||
|
||||
// Check that the LHS is "upTo as base.u64".
|
||||
// Check that the LHS is "(upTo + adj) as base.u64".
|
||||
lhs := x.LHS().AsExpr()
|
||||
if lhs.Operator() != t.IDXBinaryAs {
|
||||
continue
|
||||
}
|
||||
llhs, lrhs := lhs.LHS().AsExpr(), lhs.RHS().AsTypeExpr()
|
||||
if !llhs.Eq(upTo) || !lrhs.Eq(typeExprU64) {
|
||||
if !lrhs.Eq(typeExprU64) {
|
||||
continue
|
||||
}
|
||||
if adj == nil {
|
||||
if !llhs.Eq(upTo) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
if (llhs.Operator() != t.IDXBinaryPlus) || !llhs.LHS().AsExpr().Eq(upTo) {
|
||||
continue
|
||||
} else if cv := llhs.RHS().AsExpr().ConstValue(); (cv == nil) || (cv.Cmp(adj) != 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the RHS is "recv.length()".
|
||||
y, method, yArgs := splitReceiverMethodArgs(x.RHS().AsExpr())
|
||||
@@ -1322,7 +1340,12 @@ check0:
|
||||
|
||||
break check0
|
||||
}
|
||||
return fmt.Errorf("check: could not prove (up_to as base.u64) <= %s.length()", recv.Str(q.tm))
|
||||
if adj == nil {
|
||||
return fmt.Errorf("check: could not prove (%s as base.u64) <= %s.length()",
|
||||
upTo.Str(q.tm), recv.Str(q.tm))
|
||||
}
|
||||
return fmt.Errorf("check: could not prove ((%s + %v) as base.u64) <= %s.length()",
|
||||
upTo.Str(q.tm), adj, recv.Str(q.tm))
|
||||
}
|
||||
|
||||
// Check "distance > 0".
|
||||
@@ -1340,7 +1363,7 @@ check1:
|
||||
}
|
||||
break check1
|
||||
}
|
||||
return fmt.Errorf("check: could not prove distance > 0")
|
||||
return fmt.Errorf("check: could not prove %s > 0", distance.Str(q.tm))
|
||||
}
|
||||
|
||||
// Check "distance <= this.history_length()".
|
||||
@@ -1372,7 +1395,8 @@ check2:
|
||||
|
||||
break check2
|
||||
}
|
||||
return fmt.Errorf("check: could not prove distance <= %s.history_length()", recv.Str(q.tm))
|
||||
return fmt.Errorf("check: could not prove %s <= %s.history_length()",
|
||||
distance.Str(q.tm), recv.Str(q.tm))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+14
-12
@@ -504,12 +504,13 @@ const (
|
||||
IDSkipU32 = ID(0x16B)
|
||||
IDSkipU32Fast = ID(0x16C)
|
||||
|
||||
IDCopyFromSlice = ID(0x170)
|
||||
IDLimitedCopyU32FromHistory = ID(0x171)
|
||||
IDLimitedCopyU32FromHistoryFast = ID(0x172)
|
||||
IDLimitedCopyU32FromReader = ID(0x173)
|
||||
IDLimitedCopyU32FromSlice = ID(0x174)
|
||||
IDLimitedCopyU32ToSlice = ID(0x175)
|
||||
IDCopyFromSlice = ID(0x170)
|
||||
IDLimitedCopyU32FromHistory = ID(0x171)
|
||||
IDLimitedCopyU32FromHistory8ByteChunksFast = ID(0x172)
|
||||
IDLimitedCopyU32FromHistoryFast = ID(0x173)
|
||||
IDLimitedCopyU32FromReader = ID(0x174)
|
||||
IDLimitedCopyU32FromSlice = ID(0x175)
|
||||
IDLimitedCopyU32ToSlice = ID(0x176)
|
||||
|
||||
// -------- 0x180 block.
|
||||
|
||||
@@ -927,12 +928,13 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
IDSkipU32: "skip_u32",
|
||||
IDSkipU32Fast: "skip_u32_fast",
|
||||
|
||||
IDCopyFromSlice: "copy_from_slice",
|
||||
IDLimitedCopyU32FromHistory: "limited_copy_u32_from_history",
|
||||
IDLimitedCopyU32FromHistoryFast: "limited_copy_u32_from_history_fast",
|
||||
IDLimitedCopyU32FromReader: "limited_copy_u32_from_reader",
|
||||
IDLimitedCopyU32FromSlice: "limited_copy_u32_from_slice",
|
||||
IDLimitedCopyU32ToSlice: "limited_copy_u32_to_slice",
|
||||
IDCopyFromSlice: "copy_from_slice",
|
||||
IDLimitedCopyU32FromHistory: "limited_copy_u32_from_history",
|
||||
IDLimitedCopyU32FromHistory8ByteChunksFast: "limited_copy_u32_from_history_8_byte_chunks_fast",
|
||||
IDLimitedCopyU32FromHistoryFast: "limited_copy_u32_from_history_fast",
|
||||
IDLimitedCopyU32FromReader: "limited_copy_u32_from_reader",
|
||||
IDLimitedCopyU32FromSlice: "limited_copy_u32_from_slice",
|
||||
IDLimitedCopyU32ToSlice: "limited_copy_u32_to_slice",
|
||||
|
||||
// -------- 0x180 block.
|
||||
|
||||
|
||||
Reference in new issue
Block a user