Re: code review 28460043: crypto/sha256: block implementation in amd64 assembly (issue 28460043)

127 views
Skip to first unread message

js...@google.com

unread,
Dec 10, 2013, 7:34:23 AM12/10/13
to a...@golang.org, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
On 2013/12/02 17:56:25, agl1 wrote:
> LGTM with nits.

> Just to confirm - the addition of |s| to |digest| is just to avoid
stack
> allocation in the block function, right?

Correct. I've reworked it so that we use stack-based allocation (which
means we have to enable stack splitting) - this resolves your other
dislike and seems to give a small performance gain.


https://codereview.appspot.com/28460043/diff/60001/src/pkg/crypto/sha256/sha256.go
> File src/pkg/crypto/sha256/sha256.go (right):


https://codereview.appspot.com/28460043/diff/60001/src/pkg/crypto/sha256/sha256.go#newcode49
> src/pkg/crypto/sha256/sha256.go:49: type schedule struct {
> The use of a new type for this seems excessive.

PTAL

https://codereview.appspot.com/28460043/

a...@golang.org

unread,
Dec 11, 2013, 11:41:45 AM12/11/13
to js...@google.com, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
*** Submitted as
https://code.google.com/p/go/source/detail?r=5de0f8743adf ***

crypto/sha256: block implementation in amd64 assembly

Benchmark on Intel(R) Xeon(R) CPU X5650  @ 2.67GHz

benchmark old ns/op new ns/op delta
BenchmarkHash8Bytes 1259 677 -46.23%
BenchmarkHash1K 14387 6749 -53.09%
BenchmarkHash8K 106006 50107 -52.73%

benchmark old MB/s new MB/s speedup
BenchmarkHash8Bytes 6.35 11.81 1.86x
BenchmarkHash1K 71.17 151.72 2.13x
BenchmarkHash8K 77.28 163.49 2.12x

R=agl
CC=golang-dev
https://codereview.appspot.com/28460043

Committer: Adam Langley <a...@golang.org>


https://codereview.appspot.com/28460043/

Donovan Hide

unread,
Dec 21, 2013, 12:07:26 PM12/21/13
to js...@google.com, Adam Langley, golang-dev, re...@codereview-hr.appspotmail.com
Hi,

are they any plans for giving the same treatment to SHA512? The proof of work algorithm for Ripple uses an unusual hash that involves taking the first 32 bytes of a SHA512 hash. Would be great if we could get similar speedups :-)


All the best,
Donovan.





https://codereview.appspot.com/28460043/

--

---You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Joel Sing

unread,
Dec 22, 2013, 1:46:40 AM12/22/13
to Donovan Hide, Adam Langley, golang-dev, re...@codereview-hr.appspotmail.com
I had planned on looking at it, but it was low on my list of priorities... however, since you asked :)

Donovan Hide

unread,
Dec 22, 2013, 6:54:53 AM12/22/13
to Joel Sing, Adam Langley, golang-dev, re...@codereview-hr.appspotmail.com
Wow, that looks extremely good to me :-)

Thank you very, very much! I'm contacting the Guinness Books to ask them to record the fastest delivery of an assembly version of a crypto hasher!

Cheers,
Donovan (busy proving work!)
Reply all
Reply to author
Forward
0 new messages