go/src
Nigel Tao 1fb4e4de26 compress/flate: use a constant hash table size for Best Speed.
This makes compress/flate's version of Snappy diverge from the upstream
golang/snappy version, but the latter has a goal of matching C++ snappy
output byte-for-byte. Both C++ and the asm version of golang/snappy can
use a smaller N for the O(N) zero-initialization of the hash table when
the input is small, even if the pure Go golang/snappy algorithm cannot:
"var table [tableSize]uint16" zeroes all tableSize elements.

For this package, we don't have the match-C++-snappy goal, so we can use
a different (constant) hash table size.

This is a small win, in terms of throughput and output size, but it also
enables us to re-use the (constant size) hash table between
encodeBestSpeed calls, avoiding the cost of zero-initializing the hash
table altogether. This will be implemented in follow-up commits.

This package's benchmarks:
name                    old speed      new speed      delta
EncodeDigitsSpeed1e4-8  72.8MB/s ± 1%  73.5MB/s ± 1%  +0.86%  (p=0.000 n=10+10)
EncodeDigitsSpeed1e5-8  77.5MB/s ± 1%  78.0MB/s ± 0%  +0.69%  (p=0.000 n=10+10)
EncodeDigitsSpeed1e6-8  82.0MB/s ± 1%  82.7MB/s ± 1%  +0.85%   (p=0.000 n=10+9)
EncodeTwainSpeed1e4-8   65.1MB/s ± 1%  65.6MB/s ± 0%  +0.78%   (p=0.000 n=10+9)
EncodeTwainSpeed1e5-8   80.0MB/s ± 0%  80.6MB/s ± 1%  +0.66%   (p=0.000 n=9+10)
EncodeTwainSpeed1e6-8   81.6MB/s ± 1%  82.1MB/s ± 1%  +0.55%  (p=0.017 n=10+10)

Input size in bytes, output size (and time taken) before and after on
some larger files:
1073741824   57269781 (  3183ms)   57269781 (  3177ms) adresser.001
1000000000  391052000 ( 11071ms)  391051996 ( 11067ms) enwik9
1911399616  378679516 ( 13450ms)  378679514 ( 13079ms) gob-stream
8558382592 3972329193 ( 99962ms) 3972329193 ( 91290ms) rawstudio-mint14.tar
 200000000  200015265 (   776ms)  200015265 (   774ms) sharnd.out

Thanks to Klaus Post for the original suggestion on cl/21021.

Change-Id: Ia4c63a8d1b92c67e1765ec5c3c8c69d289d9a6ce
Reviewed-on: https://go-review.googlesource.com/22604
Reviewed-by: Russ Cox <rsc@golang.org>
2016-04-29 14:00:39 +00:00
..
archive archive/tar: style nit: s/nano_buf/nanoBuf/ 2016-04-15 21:29:18 +00:00
bufio all: replace magic 0x80 with named constant utf8.RuneSelf 2016-04-10 15:15:57 +00:00
builtin
bytes all: remove unnecessary type conversions 2016-04-15 07:31:45 +00:00
cmd cmd/compile/internal/gc: bv.go cleanup 2016-04-29 13:22:15 +00:00
compress compress/flate: use a constant hash table size for Best Speed. 2016-04-29 14:00:39 +00:00
container container/heap: correct number of elements in BenchmarkDup 2016-04-20 15:26:05 +00:00
context context: produce a nicer panic message for a nil WithValue key 2016-04-29 03:20:51 +00:00
crypto crypto/tls: allow renegotiation to be handled by a client. 2016-04-28 17:56:28 +00:00
database/sql all: delete dead non-test code 2016-03-25 06:28:13 +00:00
debug debug/pe: .bss section must contain only zeros 2016-04-29 02:58:42 +00:00
encoding encoding/json: add Encoder.DisableHTMLEscaping 2016-04-22 21:35:56 +00:00
errors
expvar expvar: Ensure strings are written as valid JSON. 2016-04-06 03:52:39 +00:00
flag flag: update test case (fix build) 2016-04-21 23:17:18 +00:00
fmt fmt: remove extra space in doc for compound objects 2016-04-17 20:07:32 +00:00
go cmd/go, go/build: add support for binary-only packages 2016-04-29 00:23:02 +00:00
hash hash/crc32: use vector instructions on s390x 2016-04-22 18:07:15 +00:00
html html/template, text/template: clarify Parse{Files,Glob} semantics 2016-04-22 02:01:54 +00:00
image image/gif: accept an out-of-bounds transparent color index. 2016-04-29 00:01:22 +00:00
index/suffixarray
internal net/http, net/http/httptrace: new package for tracing HTTP client requests 2016-04-28 20:56:38 +00:00
io io: document WriteString calls Write exactly once 2016-04-12 01:03:51 +00:00
log
math math/big: more tests, documentation for Flot gob marshalling 2016-04-20 21:16:21 +00:00
mime all: standardize RFC mention format 2016-04-12 21:07:52 +00:00
net net: remove unneeded tags from dnsRR structs 2016-04-28 21:34:06 +00:00
os os/exec: fix variable shadow, don't leak goroutine 2016-04-28 20:56:25 +00:00
path all: use bytes.Equal, bytes.Contains and strings.Contains, again 2016-04-11 15:16:54 +00:00
reflect reflect: fix strings of SliceOf-created types 2016-04-27 18:07:24 +00:00
regexp regexp: add a harder regexp to the benchmarks 2016-04-27 16:40:22 +00:00
runtime runtime: drop _SigUnblock for SIGSYS on Linux 2016-04-28 21:48:44 +00:00
sort all: delete dead non-test code 2016-03-25 06:28:13 +00:00
strconv strconv: fix ParseFloat for special forms of zero values 2016-04-19 22:39:43 +00:00
strings all: remove unnecessary type conversions 2016-04-15 07:31:45 +00:00
sync all: remove unnecessary type conversions 2016-04-15 07:31:45 +00:00
syscall syscall: fix uint64->int cast of control message header 2016-04-27 20:10:09 +00:00
testing testing: add matching of subtest 2016-04-21 19:58:31 +00:00
text html/template, text/template: clarify Parse{Files,Glob} semantics 2016-04-22 02:01:54 +00:00
time time: print zero duration as 0s, not 0 2016-04-21 22:07:59 +00:00
unicode unicode: improve SimpleFold performance for ascii 2016-04-26 21:59:50 +00:00
unsafe
vendor/golang.org/x/net/http2/hpack all: fix spelling mistakes 2016-04-03 17:03:15 +00:00
Make.dist
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash cmd/compile: switch to compact export format by default 2016-04-27 16:59:55 +00:00
iostest.bash
make.bash
make.bat
make.rc
naclmake.bash src: split nacltest.bash into naclmake.bash and keep nacltest.bash 2016-04-12 02:03:34 +00:00
nacltest.bash src: split nacltest.bash into naclmake.bash and keep nacltest.bash 2016-04-12 02:03:34 +00:00
race.bash
race.bat
run.bash
run.bat
run.rc