-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
Comments
bytes.Compare does this check, at least for 386 and amd64. Maybe the other archs need it? |
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. |
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
|
CL https://golang.org/cl/13881 mentions this issue. |
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>
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>
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 ? |
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. |
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
|
CL https://golang.org/cl/13901 mentions this issue. |
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 instrumentingbytes.Compare
and running some large, real-world code?The text was updated successfully, but these errors were encountered: