summaryrefslogtreecommitdiff
path: root/src/compress/bzip2/huffman.go
Commit message (Collapse)AuthorAgeFilesLines
* compress/bzip2: remove bit-tricksIlya Tocar2018-03-211-14/+18
| | | | | | | | | | | | | | | | | | | | | | Since compiler is now able to generate conditional moves, we can replace bit-tricks with simple if/else. This even results in slightly better performance: name old time/op new time/op delta DecodeDigits-6 13.4ms ± 4% 13.0ms ± 2% -2.63% (p=0.003 n=10+10) DecodeTwain-6 37.5ms ± 1% 36.3ms ± 1% -3.03% (p=0.000 n=10+9) DecodeRand-6 4.23ms ± 1% 4.07ms ± 1% -3.67% (p=0.000 n=10+9) name old speed new speed delta DecodeDigits-6 7.47MB/s ± 4% 7.67MB/s ± 2% +2.69% (p=0.002 n=10+10) DecodeTwain-6 10.4MB/s ± 1% 10.7MB/s ± 1% +3.25% (p=0.000 n=10+8) DecodeRand-6 3.87MB/s ± 1% 4.03MB/s ± 2% +4.08% (p=0.000 n=10+10) diff --git a/src/compress/bzip2/huffman.go b/src/compress/bzip2/huffman.go Change-Id: Ie96ef1a9e07013b07e78f22cdccd531f3341caca Reviewed-on: https://go-review.googlesource.com/102015 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> Reviewed-by: Joe Tsai <joetsai@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* compress/bzip2: use sort.Slice in huffman.goJoe Kyo2018-02-171-43/+17
| | | | | | | | Change-Id: Ie4d23cdb81473a4c989a977a127479cf825084dc Reviewed-on: https://go-review.googlesource.com/77850 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* compress/bzip2: remove dead code in huffman.goJoe Tsai2017-05-241-4/+0
| | | | | | | | | | | | | | | | | The logic performs a series of shifts, which are useless given that they are followed by an assignment that overrides the value of the previous computation. I suspect (but cannot prove) that this is leftover logic from an original approach that attempted to store both the Huffman code and the length within the same variable instead of using two different variables as it currently does now. Fixes #17949 Change-Id: Ibf6c807c6cef3b28bfdaf2b68d9bc13503ac21b2 Reviewed-on: https://go-review.googlesource.com/44091 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* compress/bzip2: make decoding fasterAlberto Donizetti2015-08-281-16/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue 6754 reports that Go bzip2 Decode function is much slower (about 2.5x in go1.5) than the Python equivalent (which is actually just a wrapper around the usual C library) on random data. Profiling the code shows that half a dozen of CMP instructions in a tight loop are responsibile for most of the execution time. This patch reduces the number of branches of the loop, greatly improving performance on random data and speeding up decoding of real data. name old time/op new time/op delta DecodeDigits-4 9.28ms ± 1% 8.05ms ± 1% -13.18% (p=0.000 n=15+14) DecodeTwain-4 28.9ms ± 2% 26.4ms ± 1% -8.57% (p=0.000 n=15+14) DecodeRand-4 3.94ms ± 1% 3.06ms ± 1% -22.45% (p=0.000 n=15+14) name old speed new speed delta DecodeDigits-4 4.65MB/s ± 1% 5.36MB/s ± 1% +15.21% (p=0.000 n=13+14) DecodeTwain-4 4.32MB/s ± 2% 4.72MB/s ± 1% +9.36% (p=0.000 n=15+14) DecodeRand-4 4.27MB/s ± 1% 5.51MB/s ± 1% +28.86% (p=0.000 n=15+14) I've run some benchmark comparing Go bzip2 implementation with the usual Linux bzip2 command (which is written in C). On my machine this patch brings go1.5 from ~2.26x to ~1.50x of bzip2 time (on 64MB random data) from ~1.70x to ~1.50x of bzip2 time (on 100MB english text) from ~2.00x to ~1.88x of bzip2 time (on 64MB /dev/zero data) Fixes #6754 Change-Id: I3cb12d2c0c2243c1617edef1edc88f05f91d26d1 Reviewed-on: https://go-review.googlesource.com/13853 Reviewed-by: Nigel Tao <nigeltao@golang.org>
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+251
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.