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

Issue 5574054: code review 5574054: math/big: assembly versions of bitLen for x86-64, 386,... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 4 months ago by dga
Modified:
13 years, 4 months ago
Reviewers:
CC:
golang-dev, minux1, gri
Visibility:
Public.

Description

math/big: assembly versions of bitLen for x86-64, 386, and ARM. Roughly 2x speedup for the internal bitLen function in arith.go. Added TestWordBitLen test. Performance differences against the new version of bitLen generic: x86-64 Macbook pro (current tip): benchmark old ns/op new ns/op delta big.BenchmarkBitLen0 6 4 -37.40% big.BenchmarkBitLen1 6 2 -51.79% big.BenchmarkBitLen2 6 2 -65.04% big.BenchmarkBitLen3 6 2 -66.10% big.BenchmarkBitLen4 6 2 -60.96% big.BenchmarkBitLen5 6 2 -55.80% big.BenchmarkBitLen8 6 2 -56.19% big.BenchmarkBitLen9 6 2 -64.73% big.BenchmarkBitLen16 7 2 -68.84% big.BenchmarkBitLen17 6 2 -67.11% big.BenchmarkBitLen31 7 2 -61.57% 386 Intel Atom (current tip): benchmark old ns/op new ns/op delta big.BenchmarkBitLen0 23 20 -13.04% big.BenchmarkBitLen1 23 20 -14.77% big.BenchmarkBitLen2 24 20 -19.28% big.BenchmarkBitLen3 25 20 -21.57% big.BenchmarkBitLen4 24 20 -16.94% big.BenchmarkBitLen5 25 20 -20.78% big.BenchmarkBitLen8 24 20 -19.28% big.BenchmarkBitLen9 25 20 -20.47% big.BenchmarkBitLen16 26 20 -23.37% big.BenchmarkBitLen17 26 20 -25.09% big.BenchmarkBitLen31 32 20 -35.51% ARM v5 SheevaPlug, previous weekly patched with bitLen: benchmark old ns/op new ns/op delta big.BenchmarkBitLen0 50 29 -41.73% big.BenchmarkBitLen1 51 29 -42.75% big.BenchmarkBitLen2 59 29 -50.08% big.BenchmarkBitLen3 60 29 -50.75% big.BenchmarkBitLen4 59 29 -50.08% big.BenchmarkBitLen5 60 29 -50.75% big.BenchmarkBitLen8 59 29 -50.08% big.BenchmarkBitLen9 60 29 -50.75% big.BenchmarkBitLen16 69 29 -57.35% big.BenchmarkBitLen17 70 29 -57.89% big.BenchmarkBitLen31 95 29 -69.07%

Patch Set 1 #

Patch Set 2 : diff -r bf7fe7752318 https://go.googlecode.com/hg/ #

Total comments: 1

Patch Set 3 : diff -r bf7fe7752318 https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 4 : diff -r 895d896f08a5 https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r 895d896f08a5 https://go.googlecode.com/hg/ #

Total comments: 2

Patch Set 6 : diff -r 895d896f08a5 https://go.googlecode.com/hg/ #

Total comments: 3

Patch Set 7 : diff -r 895d896f08a5 https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -4 lines) Patch
M src/pkg/math/big/arith.go View 1 1 chunk +1 line, -1 line 0 comments Download
M src/pkg/math/big/arith_386.s View 1 2 3 4 5 2 chunks +12 lines, -1 line 0 comments Download
M src/pkg/math/big/arith_amd64.s View 1 2 3 4 5 2 chunks +12 lines, -1 line 0 comments Download
M src/pkg/math/big/arith_arm.s View 1 2 3 2 chunks +10 lines, -1 line 0 comments Download
M src/pkg/math/big/arith_decl.go View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/math/big/arith_test.go View 1 2 3 4 1 chunk +23 lines, -0 lines 0 comments Download

Messages

Total messages: 17
dga
Hello golang-dev@googlegroups.com (cc: golang-dev@googlegroups.com), I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 4 months ago (2012-01-24 02:33:50 UTC) #1
minux1
http://codereview.appspot.com/5574054/diff/1001/src/pkg/math/big/arith_arm.s File src/pkg/math/big/arith_arm.s (right): http://codereview.appspot.com/5574054/diff/1001/src/pkg/math/big/arith_arm.s#newcode317 src/pkg/math/big/arith_arm.s:317: WORD $0xe16f0f10 I think this line needs a comment ...
13 years, 4 months ago (2012-01-24 02:39:16 UTC) #2
dga
Hello golang-dev@googlegroups.com, minux.ma@gmail.com (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 4 months ago (2012-01-24 02:42:20 UTC) #3
dga
On 2012/01/24 02:39:16, minux wrote: http://codereview.appspot.com/5574054/diff/1001/src/pkg/math/big/arith_arm.s#newcode317 > src/pkg/math/big/arith_arm.s:317: WORD $0xe16f0f10 > I think this line ...
13 years, 4 months ago (2012-01-24 02:43:00 UTC) #4
gri
http://codereview.appspot.com/5574054/diff/6001/src/pkg/math/big/arith_386.s File src/pkg/math/big/arith_386.s (right): http://codereview.appspot.com/5574054/diff/6001/src/pkg/math/big/arith_386.s#newcode248 src/pkg/math/big/arith_386.s:248: // divWVW(z* Word, xn Word, x []Word, y Word) ...
13 years, 4 months ago (2012-01-25 17:44:31 UTC) #5
gri
Also: There should be a Test function in arith_test.go for bitLen (probably TestbitLen since TestBitLen ...
13 years, 4 months ago (2012-01-25 17:52:06 UTC) #6
dga
On 2012/01/25 17:44:31, gri wrote: > TEXT ·bitLen(SB),7,$0 > BSRQ x+0(FP), AX > JZ Z1 ...
13 years, 4 months ago (2012-01-25 18:53:04 UTC) #7
dga
> (BSR only updates the dest register if the value was non-zero); needs > MOVQ ...
13 years, 4 months ago (2012-01-25 19:42:41 UTC) #8
dga
Hello golang-dev@googlegroups.com, minux.ma@gmail.com, gri@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 4 months ago (2012-01-25 19:51:02 UTC) #9
dga
Hello golang-dev@googlegroups.com, minux.ma@gmail.com, gri@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 4 months ago (2012-01-25 19:52:43 UTC) #10
gri
Please add the test function. TestWordBitLen is fine. http://codereview.appspot.com/5574054/diff/2019/src/pkg/math/big/arith_386.s File src/pkg/math/big/arith_386.s (right): http://codereview.appspot.com/5574054/diff/2019/src/pkg/math/big/arith_386.s#newcode269 src/pkg/math/big/arith_386.s:269: MOVL ...
13 years, 4 months ago (2012-01-25 21:55:08 UTC) #11
dga
Agreed - was just about to say the same thing about the branch. I'd looked ...
13 years, 4 months ago (2012-01-25 21:59:49 UTC) #12
dga
Hello golang-dev@googlegroups.com, minux.ma@gmail.com, gri@golang.org (cc: golang-dev@googlegroups.com), Please take another look.
13 years, 4 months ago (2012-01-25 22:08:41 UTC) #13
gri
Close, but there's a bug in your comments (or your code). Please use my simple ...
13 years, 4 months ago (2012-01-25 22:23:19 UTC) #14
gri
LGTM http://codereview.appspot.com/5574054/diff/9002/src/pkg/math/big/arith_test.go File src/pkg/math/big/arith_test.go (right): http://codereview.appspot.com/5574054/diff/9002/src/pkg/math/big/arith_test.go#newcode356 src/pkg/math/big/arith_test.go:356: y = (y << 1) | 0x1 On ...
13 years, 4 months ago (2012-01-25 23:03:09 UTC) #15
gri
*** Submitted as 77457a85f621 *** math/big: assembly versions of bitLen for x86-64, 386, and ARM. ...
13 years, 4 months ago (2012-01-25 23:04:19 UTC) #16
dga
13 years, 4 months ago (2012-01-25 23:09:39 UTC) #17
On 2012/01/25 22:23:19, gri wrote:
> 
> I assume you have updated the performance numbers to match this last version?

Yup.  The change is that on amd64, bitLen(0) got a bit slower (~4 ns/op) because
of the jump, but it's still quite a bit faster than the non-asm version.  The
other numbers and platforms were unchanged.  I figure that a caller who thinks
they're going to be feeding a lot of zeros in to bitLen can do the test
themselves.
Sign in to reply to this message.

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