1
0
mirror of https://github.com/golang/go synced 2024-10-04 08:21:22 -06:00
go/src
Nick Craig-Wood 107d18299c crypto/sha1: Optimise FUNC1 with alternate formulation
According to Wikipedia: http://en.wikipedia.org/wiki/SHA-1
there is an alternate formulation for the FUNC1 transform,
namely

f1 = d xor (b and (c xor d))

instead of

f1 = (b and c) or ((not b) and d)

This reduces the instruction count of FUNC1 from 6 to 4 and
makes about 5% speed improvement on amd64 and suprisingly 17%
on 386.

amd64 Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          506          499   -1.38%
BenchmarkHash1K             3099         2961   -4.45%
BenchmarkHash8K            22292        21243   -4.71%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        15.80        16.00    1.01x
BenchmarkHash1K           330.40       345.82    1.05x
BenchmarkHash8K           367.48       385.63    1.05x

i386 Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          647          615   -4.95%
BenchmarkHash1K             3673         3161  -13.94%
BenchmarkHash8K            26141        22374  -14.41%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        12.35        13.01    1.05x
BenchmarkHash1K           278.74       323.94    1.16x
BenchmarkHash8K           313.37       366.13    1.17x

The improvements on an Intel(R) Core(TM) i7-4770K CPU @
3.50GHz were almost identical.

R=golang-dev, r, hanwen
CC=golang-dev, rsc
https://golang.org/cl/19910043
2013-12-12 11:26:36 -08:00
..
cmd cmd/5a, cmd/6a, cmd/8a: fix .y files to match y.tab.[ch] 2013-12-11 12:11:37 -05:00
lib9 all: compiler/bootstrap for dragonfly/amd64 2013-08-24 01:18:04 +10:00
libbio build: do not use the host's libbio on Plan 9 2013-12-09 18:39:58 -05:00
liblink liblink: fix extern register accesses on Plan 9 (386) 2013-12-09 18:48:44 -05:00
libmach libmach: accept OS X binary generated by external linker 2013-09-10 11:50:34 -07:00
pkg crypto/sha1: Optimise FUNC1 with alternate formulation 2013-12-12 11:26:36 -08:00
all.bash
all.bat
all.rc
clean.bash
clean.bat
clean.rc
make.bash cmd/dist, build: support building statically linked toolchain 2013-10-01 23:44:20 -04:00
make.bat cmd/dist: fix windows build. 2013-08-02 14:29:04 -07:00
Make.dist
make.rc build: fix make.rc on Plan 9 2013-05-24 13:55:19 -07:00
race.bash race.bash, race.bat: build a race enabled cmd/cgo before trying to use it 2013-09-29 10:34:41 +10:00
race.bat race.bash, race.bat: build a race enabled cmd/cgo before trying to use it 2013-09-29 10:34:41 +10:00
run.bash cgo: enable cgo on dragonfly 2013-09-04 15:19:21 -07:00
run.bat runtime/race: add end-to-end test on windows 2013-08-15 12:13:00 +10:00
run.rc build: remove builder from test suite (fix build) 2013-08-01 13:49:00 +10:00
sudo.bash cmd/cov: delete 2013-05-24 11:06:06 -07:00