[go] internal/bytealg: use NEON for compare_arm64.s large-input path

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Jul 16, 2026, 12:48:46 PM (yesterday) Jul 16
to Gerrit Bot, Mauri de Souza Meneguzzo, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Michael Pratt, Keith Randall, Keith Randall, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
internal/bytealg: use NEON for compare_arm64.s large-input path

Replace the scalar chunk loop with a 64-byte/iter NEON loop.

For inputs >= 64 bytes, each iteration loads and compares 64 bytes from
both sides using NEON. The compare results are reduced to a single byte;
zero indicates a mismatch.

On mismatch, both pointers are rewound by 64 bytes and the existing
scalar chunk16 path locates the first differing byte pair and produces
the lexicographic result. This fallback is taken at most once.

Inputs < 64 bytes continue to use the existing scalar chunk16 and tail
paths unchanged.

This brings the overall structure closer to equal_arm64.s.

goos: darwin
goarch: arm64
pkg: bytes
cpu: Apple M3 Pro
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
CompareBytesBigUnaligned/offset=1-11 26.55µ ± 1% 19.21µ ± 1% -27.63% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=2-11 26.83µ ± 3% 19.11µ ± 1% -28.78% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=3-11 26.59µ ± 1% 19.28µ ± 2% -27.50% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=4-11 26.49µ ± 1% 19.11µ ± 1% -27.84% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=5-11 27.04µ ± 3% 19.05µ ± 1% -29.54% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=6-11 27.12µ ± 1% 18.92µ ± 1% -30.24% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=7-11 27.00µ ± 0% 18.90µ ± 0% -30.01% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=0-11 26.56µ ± 1% 18.01µ ± 1% -32.20% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=1-11 27.27µ ± 1% 19.43µ ± 0% -28.77% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=2-11 26.83µ ± 2% 18.68µ ± 1% -30.38% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=3-11 27.24µ ± 0% 19.45µ ± 0% -28.62% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=4-11 27.07µ ± 1% 18.67µ ± 1% -31.03% (p=0.000 n=7+10)
geomean 26.88µ 10.82µ -29.39%

│ old.txt │ new.txt │
│ B/s │ B/s vs base │
CompareBytesBigUnaligned/offset=1-11 36.78Gi ± 1% 50.82Gi ± 1% +38.18% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=2-11 36.40Gi ± 3% 51.11Gi ± 1% +40.41% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=3-11 36.73Gi ± 1% 50.66Gi ± 2% +37.93% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=4-11 36.87Gi ± 1% 51.09Gi ± 1% +38.59% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=5-11 36.12Gi ± 3% 51.27Gi ± 1% +41.92% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=6-11 36.00Gi ± 1% 51.61Gi ± 1% +43.35% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=7-11 36.17Gi ± 0% 51.68Gi ± 0% +42.88% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=0-11 36.77Gi ± 1% 54.23Gi ± 1% +47.48% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=1-11 35.81Gi ± 1% 50.27Gi ± 0% +40.39% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=2-11 36.40Gi ± 2% 52.29Gi ± 1% +43.64% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=3-11 35.85Gi ± 0% 50.22Gi ± 0% +40.09% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=4-11 36.07Gi ± 1% 52.30Gi ± 1% +45.00% (p=0.000 n=7+10)
geomean 36.33Gi 90.30Gi +41.63%
Change-Id: I4ce9a26f7d434eb4f6447d8a5cbebee5d0901753
GitHub-Last-Rev: 1bf14dc111f1a848cce2193af0f17170b1dc7e73
GitHub-Pull-Request: golang/go#79800
Auto-Submit: Keith Randall <k...@golang.org>
Reviewed-by: Michael Pratt <mpr...@google.com>
Reviewed-by: Keith Randall <k...@golang.org>
Reviewed-by: Keith Randall <k...@google.com>
Files:
  • M src/internal/bytealg/compare_arm64.s
Change size: M
Delta: 1 file changed, 47 insertions(+), 29 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I4ce9a26f7d434eb4f6447d8a5cbebee5d0901753
Gerrit-Change-Number: 786560
Gerrit-PatchSet: 7
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@golang.org>
Gerrit-Reviewer: Keith Randall <k...@google.com>
Gerrit-Reviewer: Mauri de Souza Meneguzzo <maur...@gmail.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages