22dfbbec7f
The flate library guarantees that the Reader will never read more bytes than is necessary. This way, the underlying io.Reader will be left exactly after the last byte of the DEFLATE stream. Formats like gzip depend on this behavior being true. As such, inflate conservatively reads the minimum symbol length in huffSym leading to many individual calls to moreBits. However, if we take advantage of the fact that every block *must* end with the EOB symbol, we can choose to read the length of the EOB symbol. Since the EOB symbol is also the most rare symbol (occuring exactly once) in a block, we can hypothesize that it is almost as long as the max symbol length, allowing huffSym to ask for more bits at the start of every loop. This increases the probabilty that the Huffman code is decoded on the first iteration of the outer for-loop. benchmark old MB/s new MB/s speedup BenchmarkDecodeDigitsSpeed1e4-4 51.05 54.31 1.06x BenchmarkDecodeDigitsSpeed1e5-4 58.86 62.24 1.06x BenchmarkDecodeDigitsSpeed1e6-4 59.63 63.13 1.06x BenchmarkDecodeDigitsDefault1e4-4 51.94 54.61 1.05x BenchmarkDecodeDigitsDefault1e5-4 63.70 69.13 1.09x BenchmarkDecodeDigitsDefault1e6-4 66.08 71.43 1.08x BenchmarkDecodeDigitsCompress1e4-4 52.25 54.56 1.04x BenchmarkDecodeDigitsCompress1e5-4 63.34 68.30 1.08x BenchmarkDecodeDigitsCompress1e6-4 66.84 70.64 1.06x BenchmarkDecodeTwainSpeed1e4-4 50.74 53.40 1.05x BenchmarkDecodeTwainSpeed1e5-4 60.77 67.03 1.10x BenchmarkDecodeTwainSpeed1e6-4 62.08 69.78 1.12x BenchmarkDecodeTwainDefault1e4-4 53.45 56.40 1.06x BenchmarkDecodeTwainDefault1e5-4 73.54 79.05 1.07x BenchmarkDecodeTwainDefault1e6-4 77.68 83.65 1.08x BenchmarkDecodeTwainCompress1e4-4 53.21 56.15 1.06x BenchmarkDecodeTwainCompress1e5-4 73.82 77.76 1.05x BenchmarkDecodeTwainCompress1e6-4 79.23 83.30 1.05x Change-Id: Ie194925c827988a380b8c2fdd13b13c4faa5d397 Reviewed-on: https://go-review.googlesource.com/15651 Reviewed-by: Nigel Tao <nigeltao@golang.org> |
||
---|---|---|
api | ||
doc | ||
lib/time | ||
misc | ||
src | ||
test | ||
.gitattributes | ||
.gitignore | ||
AUTHORS | ||
CONTRIBUTING.md | ||
CONTRIBUTORS | ||
favicon.ico | ||
LICENSE | ||
PATENTS | ||
README.md | ||
robots.txt |
The Go Programming Language
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
For documentation about how to install and use Go, visit https://golang.org/ or load doc/install-source.html in your web browser.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Go is the work of hundreds of contributors. We appreciate your help!
To contribute, please read the contribution guidelines: https://golang.org/doc/contribute.html
Note that we do not accept pull requests and that we use the issue tracker for bug reports and proposals only. Please ask questions on https://forum.golangbridge.org or https://groups.google.com/forum/#!forum/golang-nuts.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
--
Binary Distribution Notes
If you have just untarred a binary Go distribution, you need to set the environment variable $GOROOT to the full path of the go directory (the one containing this file). You can omit the variable if you unpack it into /usr/local/go, or if you rebuild from sources by running all.bash (see doc/install-source.html). You should also add the Go binary directory $GOROOT/bin to your shell's path.
For example, if you extracted the tar file into $HOME/go, you might put the following in your .profile:
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
See https://golang.org/doc/install or doc/install.html for more details.