Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bytes: do a pointer equality check in cmpbody on arm, arm64, pcc #11336

Closed
josharian opened this issue Jun 22, 2015 · 8 comments
Closed

bytes: do a pointer equality check in cmpbody on arm, arm64, pcc #11336

josharian opened this issue Jun 22, 2015 · 8 comments

Comments

@josharian
Copy link
Contributor

eqstr checks for pointer equality before looping over the body. bytes.Compare could do the same. The obvious question is whether this is a common enough case to warrant paying the price. I'm not sure how to gather data make this determination. Perhaps by instrumenting bytes.Compare and running some large, real-world code?

@josharian josharian added this to the Go1.6 milestone Jun 22, 2015
@randall77
Copy link
Contributor

bytes.Compare does this check, at least for 386 and amd64. Maybe the other archs need it?

@josharian josharian changed the title bytes: do a pointer equality check in Compare? bytes: do a pointer equality check in cmpbody on arm, arm64, pcc Jun 24, 2015
@josharian
Copy link
Contributor Author

Yep, missing only on arm, arm64, and pcc (in virtue of the fact that ppc doesn't have an asm byte.Compare).

arm64 also appears to be missing a pointer equality check in eqstring.

@davecheney
Copy link
Contributor

The last one is almost certainly my fault.

I'd prefer to leave this til 1.6.

On Thu, 25 Jun 2015 03:09 Josh Bleecher Snyder notifications@github.com
wrote:

Yep, missing only on arm, arm64, and pcc (in virtue of the fact that ppc
doesn't have an asm byte.Compare).

arm64 also appears to be missing a pointer equality check in eqstring.


Reply to this email directly or view it on GitHub
#11336 (comment).

@josharian josharian modified the milestones: Go1.6, Go1.6Early Jun 29, 2015
@gopherbot
Copy link

CL https://golang.org/cl/13881 mentions this issue.

davecheney added a commit that referenced this issue Aug 24, 2015
Updates #11336

Follow the lead of amd64 do a pointer equality check
before comparing string/byte contents on arm.

BenchmarkCompareBytesEqual-4               208             211             +1.44%
BenchmarkCompareBytesToNil-4               83.6            81.8            -2.15%
BenchmarkCompareBytesEmpty-4               80.2            75.2            -6.23%
BenchmarkCompareBytesIdentical-4           208             75.2            -63.85%
BenchmarkCompareBytesSameLength-4          126             128             +1.59%
BenchmarkCompareBytesDifferentLength-4     128             130             +1.56%
BenchmarkCompareBytesBigUnaligned-4        14192804        14060971        -0.93%
BenchmarkCompareBytesBig-4                 12277313        12128193        -1.21%
BenchmarkCompareBytesBigIdentical-4        9385046         78.5            -100.00%

Change-Id: I5b24620018688c5fe04b6ff6743a24c4ce225788
Reviewed-on: https://go-review.googlesource.com/13881
Reviewed-by: Keith Randall <khr@golang.org>
mk0x9 pushed a commit to mk0x9/go that referenced this issue Aug 25, 2015
Updates golang#11336

Follow the lead of amd64 by doing a pointer equality check
before comparing string/byte contents on arm64.

BenchmarkCompareBytesEqual-8               25.8           26.3           +1.94%
BenchmarkCompareBytesToNil-8               9.59           9.59           +0.00%
BenchmarkCompareBytesEmpty-8               9.59           9.17           -4.38%
BenchmarkCompareBytesIdentical-8           26.3           9.17           -65.13%
BenchmarkCompareBytesSameLength-8          16.3           16.3           +0.00%
BenchmarkCompareBytesDifferentLength-8     16.3           16.3           +0.00%
BenchmarkCompareBytesBigUnaligned-8        1132038        1131409        -0.06%
BenchmarkCompareBytesBig-8                 1126758        1128470        +0.15%
BenchmarkCompareBytesBigIdentical-8        1084366        9.17           -100.00%

Change-Id: Id7125c31957eff1ddb78897d4511bd50e79af3f7
Reviewed-on: https://go-review.googlesource.com/13885
Reviewed-by: Keith Randall <khr@golang.org>
@davecheney
Copy link
Contributor

The only one remaining is ppc64x, which doesn't have integrated bytes.Compare yet.

@randall77 @minux what do you want to do ? Leave this issue open, or close it and remember this optimisation when someone gets around to doing bytes.Compare on ppc64 ?

@randall77
Copy link
Contributor

Let's add a comment in runtime/noasm.go:Compare that assembly versions should do this optimization. (Or maybe we could actually do the optimization in Go?) Then anyone implementing ppc will know to do it, starting from either from the Go source or another arch's asm source.

@davecheney
Copy link
Contributor

SGTM. I'll do it this week and close the issue.

FWIW is anyone planning on doing this for 1.6 ?

On Tue, Aug 25, 2015 at 1:54 PM, Keith Randall notifications@github.com
wrote:

Let's add a comment in runtime/noasm.go:Compare that assembly versions
should do this optimization. (Or maybe we could actually do the
optimization in Go?) Then anyone implementing ppc will know to do it,
starting from either from the Go source or another arch's asm source.


Reply to this email directly or view it on GitHub
#11336 (comment).

@gopherbot
Copy link

CL https://golang.org/cl/13901 mentions this issue.

@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants