Hi.
Played with go-snappy (
http://code.google.com/p/snappy-go/)
performance improving using sparse arrays
(
http://research.swtch.com/sparse). Got mixed results, some numbers
are better while some others are worse:
(17:14) jnml@fsc-r550:~/go/misc$ ./benchcmp ~/tmp/old-tip.txt ~/tmp/new-tip.txt
benchmark old ns/op new ns/op delta
BenchmarkDecodeWords1e3 6887 6891 +0.06%
BenchmarkDecodeWords1e4 67504 67037 -0.69%
BenchmarkDecodeWords1e5 691593 692624 +0.15%
BenchmarkDecodeWords1e6 6108067 6020448 -1.43%
BenchmarkEncodeWords1e3 24139 16070 -33.43%
BenchmarkEncodeWords1e4 157504 148469 -5.74%
BenchmarkEncodeWords1e5 1464519 1683214 +14.93%
BenchmarkEncodeWords1e6 11771157 13947030 +18.48%
benchmark old MB/s new MB/s speedup
BenchmarkDecodeWords1e3 98.58 98.52 1.00x
BenchmarkDecodeWords1e4 89.24 89.86 1.01x
BenchmarkDecodeWords1e5 89.77 89.64 1.00x
BenchmarkDecodeWords1e6 85.36 86.60 1.01x
BenchmarkEncodeWords1e3 41.43 62.23 1.50x
BenchmarkEncodeWords1e4 63.49 67.35 1.06x
BenchmarkEncodeWords1e5 68.28 59.41 0.87x
BenchmarkEncodeWords1e6 84.95 71.70 0.84x
benchmark old allocs new allocs delta
BenchmarkDecodeWords1e3 0 0 n/a%
BenchmarkDecodeWords1e4 0 0 n/a%
BenchmarkDecodeWords1e5 0 0 n/a%
BenchmarkDecodeWords1e6 0 0 n/a%
BenchmarkEncodeWords1e3 1 0 -100.00%
BenchmarkEncodeWords1e4 1 0 -100.00%
BenchmarkEncodeWords1e5 1 0 -100.00%
BenchmarkEncodeWords1e6 1 0 -100.00%
benchmark old bytes new bytes delta
BenchmarkDecodeWords1e3 0 0 n/a%
BenchmarkDecodeWords1e4 0 5 n/a%
BenchmarkDecodeWords1e5 0 59 n/a%
BenchmarkDecodeWords1e6 0 598 n/a%
BenchmarkEncodeWords1e3 135168 2 -100.00%
BenchmarkEncodeWords1e4 135168 29 -99.98%
BenchmarkEncodeWords1e5 135168 299 -99.78%
BenchmarkEncodeWords1e6 135168 2990 -97.79%
(17:16) jnml@fsc-r550:~/go/misc$
Additionally, there is an API change. The sparse array (used for the
hash table) is now an Encoder struct and Encode is its method. Reason:
No need to (re)initialize the (reusable) Encoder (less allocations,
zero additional initialization overhead). Docs:
----
type Encoder struct {
// contains filtered or unexported fields
}
Encoder provides snappy encoding. A zero value of Encoder is ready for
use. After an invocation of Encode, Encoder is reusable for another
invocation of Encode.
func (e *Encoder) Encode(dst, src []byte) ([]byte, error)
Encode returns the encoded form of src. The returned slice may be a
sub- slice of dst if dst was large enough to hold the entire encoded
block. Otherwise, a newly allocated slice will be returned. It is
valid to pass a nil dst.
----
Not able to evaluate it properly, seeking opinions of others. Is it worth a CL?
Thanks.
-j