FAQ
Reviewers: nigeltao,

Message:
Hello nigeltao@golang.org (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/snappy-go/


Description:
snappy-go: Small encoding speed improvements.

Not sure if big enough to consider.

benchmark old ns/op new ns/op delta
BenchmarkWordsDecode1e3 6695 6695 +0.00%
BenchmarkWordsDecode1e4 66295 66324 +0.04%
BenchmarkWordsDecode1e5 683764 683401 -0.05%
BenchmarkWordsDecode1e6 5957201 5958060 +0.01%
BenchmarkWordsEncode1e3 22069 21079 -4.49%
BenchmarkWordsEncode1e4 130594 122500 -6.20%
BenchmarkWordsEncode1e5 1344033 1259334 -6.30%
BenchmarkWordsEncode1e6 10790380 10433710 -3.31%
Benchmark_UFlat0 322380 322629 +0.08%
Benchmark_UFlat1 3020234 3019993 -0.01%
Benchmark_UFlat2 34780 34703 -0.22%
Benchmark_UFlat3 105514 105439 -0.07%
Benchmark_UFlat4 1293924 1293729 -0.02%
Benchmark_UFlat5 115789 116242 +0.39%
Benchmark_UFlat6 52528 52536 +0.02%
Benchmark_UFlat7 17628 17604 -0.14%
Benchmark_UFlat8 4011431 4014931 +0.09%
Benchmark_UFlat9 927759 928942 +0.13%
Benchmark_UFlat10 802330 804713 +0.30%
Benchmark_UFlat11 2499562 2499412 -0.01%
Benchmark_UFlat12 3237869 3240822 +0.09%
Benchmark_UFlat13 1425709 1427131 +0.10%
Benchmark_UFlat14 192463 193185 +0.38%
Benchmark_UFlat15 22708 22712 +0.02%
Benchmark_UFlat16 326083 325980 -0.03%
Benchmark_UFlat17 824631 824969 +0.04%
Benchmark_ZFlat0 547747 541689 -1.11%
Benchmark_ZFlat1 7584140 6945557 -8.42%
Benchmark_ZFlat2 1876283 1365759 -27.21%
Benchmark_ZFlat3 1215468 924872 -23.91%
Benchmark_ZFlat4 2149307 2150477 +0.05%
Benchmark_ZFlat5 253761 236758 -6.70%
Benchmark_ZFlat6 105331 100136 -4.93%
Benchmark_ZFlat7 43800 41979 -4.16%
Benchmark_ZFlat8 6811070 6807188 -0.06%
Benchmark_ZFlat9 1818855 1733550 -4.69%
Benchmark_ZFlat10 1606930 1519209 -5.46%
Benchmark_ZFlat11 4890796 4670013 -4.51%
Benchmark_ZFlat12 6394522 6076049 -4.98%
Benchmark_ZFlat13 2379396 2368835 -0.44%
Benchmark_ZFlat14 410782 380074 -7.48%
Benchmark_ZFlat15 56660 51938 -8.33%
Benchmark_ZFlat16 559311 557550 -0.31%
Benchmark_ZFlat17 1366589 1361254 -0.39%

benchmark old MB/s new MB/s speedup
BenchmarkWordsDecode1e3 149.36 149.34 1.00x
BenchmarkWordsDecode1e4 150.84 150.77 1.00x
BenchmarkWordsDecode1e5 146.25 146.33 1.00x
BenchmarkWordsDecode1e6 167.86 167.84 1.00x
BenchmarkWordsEncode1e3 45.31 47.44 1.05x
BenchmarkWordsEncode1e4 76.57 81.63 1.07x
BenchmarkWordsEncode1e5 74.40 79.41 1.07x
BenchmarkWordsEncode1e6 92.68 95.84 1.03x
Benchmark_UFlat0 317.64 317.39 1.00x
Benchmark_UFlat1 232.46 232.48 1.00x
Benchmark_UFlat2 3650.22 3658.32 1.00x
Benchmark_UFlat3 894.00 894.63 1.00x
Benchmark_UFlat4 316.56 316.60 1.00x
Benchmark_UFlat5 212.48 211.65 1.00x
Benchmark_UFlat6 212.26 212.23 1.00x
Benchmark_UFlat7 211.08 211.37 1.00x
Benchmark_UFlat8 256.70 256.48 1.00x
Benchmark_UFlat9 163.93 163.72 1.00x
Benchmark_UFlat10 156.02 155.56 1.00x
Benchmark_UFlat11 170.73 170.74 1.00x
Benchmark_UFlat12 148.82 148.68 1.00x
Benchmark_UFlat13 359.97 359.61 1.00x
Benchmark_UFlat14 198.69 197.94 1.00x
Benchmark_UFlat15 186.14 186.11 1.00x
Benchmark_UFlat16 363.67 363.79 1.00x
Benchmark_UFlat17 223.52 223.43 1.00x
Benchmark_ZFlat0 186.95 189.04 1.01x
Benchmark_ZFlat1 92.57 101.08 1.09x
Benchmark_ZFlat2 67.66 92.96 1.37x
Benchmark_ZFlat3 77.61 101.99 1.31x
Benchmark_ZFlat4 190.57 190.47 1.00x
Benchmark_ZFlat5 96.95 103.92 1.07x
Benchmark_ZFlat6 105.86 111.35 1.05x
Benchmark_ZFlat7 84.95 88.64 1.04x
Benchmark_ZFlat8 151.19 151.27 1.00x
Benchmark_ZFlat9 83.62 87.73 1.05x
Benchmark_ZFlat10 77.90 82.40 1.06x
Benchmark_ZFlat11 87.26 91.38 1.05x
Benchmark_ZFlat12 75.36 79.30 1.05x
Benchmark_ZFlat13 215.69 216.65 1.00x
Benchmark_ZFlat14 93.09 100.61 1.08x
Benchmark_ZFlat15 74.60 81.38 1.09x
Benchmark_ZFlat16 212.03 212.69 1.00x
Benchmark_ZFlat17 134.88 135.40 1.00x

Please review this at https://codereview.appspot.com/8360044/

Affected files:
M snappy/encode.go


Index: snappy/encode.go
===================================================================
--- a/snappy/encode.go
+++ b/snappy/encode.go
@@ -109,10 +109,11 @@
t int // The last position with the same hash as s.
lit int // The start position of any pending literal bytes.
)
- for s+3 < len(src) {
+ for lim := len(src) - 3; s < lim; {
// Update the hash table.
b0, b1, b2, b3 := src[s], src[s+1], src[s+2], src[s+3]
h := uint32(b0) | uint32(b1)<<8 | uint32(b2)<<16 | uint32(b3)<<24
+ more:
p := &table[(h*0x1e35a7bd)>>shift]
// We need to to store values in [-1, inf) in table. To save
// some initialization time, (re)use the table's zero value
@@ -122,7 +123,13 @@
// If t is invalid or src[s:s+4] differs from src[t:t+4], accumulate a
literal byte.
if t < 0 || s-t >= maxOffset || b0 != src[t] || b1 != src[t+1] || b2 !=
src[t+2] || b3 != src[t+3] {
s++
- continue
+ if s >= lim {
+ break
+ }
+
+ b0, b1, b2, b3 = b1, b2, b3, src[s+3]
+ h = h>>8 | uint32(b3)<<24
+ goto more
}
// Otherwise, we have a match. First, emit any pending literal bytes.
if lit != s {


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedApr 8, '13 at 10:28a
activeApr 8, '13 at 10:28a
posts1
users1
websitegolang.org

1 user in discussion

0xjnml: 1 post

People

Translate

site design / logo © 2022 Grokbase