Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3270)

Issue 19910043: code review 19910043: crypto/sha1: Optimise FUNC1 with alternate formulation (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by Nick Craig-Wood
Modified:
10 years, 3 months ago
Reviewers:
r
CC:
golang-dev, r, hanwen-google, rsc
Visibility:
Public.

Description

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.

Patch Set 1 #

Patch Set 2 : diff -r 746466b52725 https://code.google.com/p/go #

Patch Set 3 : diff -r 746466b52725 https://code.google.com/p/go #

Patch Set 4 : diff -r 490e62ef6da8 https://code.google.com/p/go #

Patch Set 5 : diff -r 490e62ef6da8 https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -12 lines) Patch
M src/pkg/crypto/sha1/sha1block_386.s View 1 1 chunk +4 lines, -6 lines 0 comments Download
M src/pkg/crypto/sha1/sha1block_amd64.s View 1 1 chunk +4 lines, -6 lines 0 comments Download

Messages

Total messages: 7
Nick Craig-Wood
Hello golang-dev@googlegroups.com (cc: rsc@golang.org), I'd like you to review this change to https://code.google.com/p/go
10 years, 5 months ago (2013-10-30 19:42:26 UTC) #1
r
Thanks but we're in a freeze for the Go 1.2 release. Please refresh this when ...
10 years, 5 months ago (2013-10-30 19:47:26 UTC) #2
hanwen-google
On Wed, Oct 30, 2013 at 8:42 PM, <nickcw@gmail.com> wrote: > > benchmark old ns/op ...
10 years, 5 months ago (2013-11-11 15:46:58 UTC) #3
rsc
cat oldbenchmarks newbenchmarks | $GOROOT/misc/benchcmp
10 years, 5 months ago (2013-11-11 15:47:33 UTC) #4
Nick Craig-Wood
Hello golang-dev@googlegroups.com, r@golang.org, hanwen@google.com (cc: golang-dev@googlegroups.com, rsc@golang.org), Please take another look.
10 years, 4 months ago (2013-12-04 16:25:36 UTC) #5
r
LGTM
10 years, 4 months ago (2013-12-12 19:26:29 UTC) #6
r
10 years, 4 months ago (2013-12-12 19:26:45 UTC) #7
*** Submitted as https://code.google.com/p/go/source/detail?r=1499033b87e8 ***

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://codereview.appspot.com/19910043

Committer: Rob Pike <r@golang.org>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b