-
Notifications
You must be signed in to change notification settings - Fork 18.4k
unicode/utf8: make DecodeRune{,InString} inlineable #75181
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
Conversation
This PR (HEAD: d205438) has been imported to Gerrit for code review.
Please visit Gerrit at https://go-review.googlesource.com/c/go/+/699675.
Important tips:
- Don't comment on this PR. All discussion takes place in Gerrit.
- You need a Gmail or other Google account to log in to Gerrit.
- To change your code in response to feedback:
- Push a new commit to the branch used by your GitHub PR.
- A new "patch set" will then appear in Gerrit.
- Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
- Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
- Multiple commits in the PR will be squashed by GerritBot.
- The title and description of the GitHub PR are used to construct the final commit message.
- Edit these as needed via the GitHub web interface (not via Gerrit or git).
- You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
- See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
Message from Jorropo:
Patch Set 1:
(1 comment)
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from jub0bs:
Patch Set 1:
(1 comment)
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
d205438
to
08bc8d1
Compare
This PR (HEAD: 08bc8d1) has been imported to Gerrit for code review.
Please visit Gerrit at https://go-review.googlesource.com/c/go/+/699675.
Important tips:
- Don't comment on this PR. All discussion takes place in Gerrit.
- You need a Gmail or other Google account to log in to Gerrit.
- To change your code in response to feedback:
- Push a new commit to the branch used by your GitHub PR.
- A new "patch set" will then appear in Gerrit.
- Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
- Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
- Multiple commits in the PR will be squashed by GerritBot.
- The title and description of the GitHub PR are used to construct the final commit message.
- Edit these as needed via the GitHub web interface (not via Gerrit or git).
- You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
- See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
2eca3da
to
361dcb9
Compare
This PR (HEAD: 361dcb9) has been imported to Gerrit for code review.
Please visit Gerrit at https://go-review.googlesource.com/c/go/+/699675.
Important tips:
- Don't comment on this PR. All discussion takes place in Gerrit.
- You need a Gmail or other Google account to log in to Gerrit.
- To change your code in response to feedback:
- Push a new commit to the branch used by your GitHub PR.
- A new "patch set" will then appear in Gerrit.
- Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
- Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
- Multiple commits in the PR will be squashed by GerritBot.
- The title and description of the GitHub PR are used to construct the final commit message.
- Edit these as needed via the GitHub web interface (not via Gerrit or git).
- You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
- See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
This change makes the fast path for ASCII characters inlineable in DecodeRune and DecodeRuneInString. Here are some benchmark results (no change to allocations): goos: darwin goarch: amd64 pkg: unicode/utf8 cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz │ old │ new │ │ sec/op │ sec/op vs base │ DecodeASCIIRune-8 2.4545n ± 2% 0.6253n ± 2% -74.52% (p=0.000 n=20) DecodeJapaneseRune-8 3.988n ± 1% 4.023n ± 1% +0.86% (p=0.050 n=20) DecodeASCIIRuneInString-8 2.4675n ± 1% 0.6264n ± 2% -74.61% (p=0.000 n=20) DecodeJapaneseRuneInString-8 3.992n ± 1% 4.001n ± 1% ~ (p=0.625 n=20) geomean 3.134n 1.585n -49.43% Note: when golang#61502 gets resolved, this change should likely be reverted. Updates golang#31666 Updates golang#48195
361dcb9
to
a6ff65b
Compare
This PR (HEAD: a6ff65b) has been imported to Gerrit for code review.
Please visit Gerrit at https://go-review.googlesource.com/c/go/+/699675.
Important tips:
- Don't comment on this PR. All discussion takes place in Gerrit.
- You need a Gmail or other Google account to log in to Gerrit.
- To change your code in response to feedback:
- Push a new commit to the branch used by your GitHub PR.
- A new "patch set" will then appear in Gerrit.
- Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
- Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
- Multiple commits in the PR will be squashed by GerritBot.
- The title and description of the GitHub PR are used to construct the final commit message.
- Edit these as needed via the GitHub web interface (not via Gerrit or git).
- You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
- See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
This PR (HEAD: cb070f0) has been imported to Gerrit for code review.
Please visit Gerrit at https://go-review.googlesource.com/c/go/+/699675.
Important tips:
- Don't comment on this PR. All discussion takes place in Gerrit.
- You need a Gmail or other Google account to log in to Gerrit.
- To change your code in response to feedback:
- Push a new commit to the branch used by your GitHub PR.
- A new "patch set" will then appear in Gerrit.
- Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
- Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
- Multiple commits in the PR will be squashed by GerritBot.
- The title and description of the GitHub PR are used to construct the final commit message.
- Edit these as needed via the GitHub web interface (not via Gerrit or git).
- You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
- See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
cb070f0
to
7e03df8
Compare
This PR (HEAD: 7e03df8) has been imported to Gerrit for code review.
Please visit Gerrit at https://go-review.googlesource.com/c/go/+/699675.
Important tips:
- Don't comment on this PR. All discussion takes place in Gerrit.
- You need a Gmail or other Google account to log in to Gerrit.
- To change your code in response to feedback:
- Push a new commit to the branch used by your GitHub PR.
- A new "patch set" will then appear in Gerrit.
- Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
- Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
- Multiple commits in the PR will be squashed by GerritBot.
- The title and description of the GitHub PR are used to construct the final commit message.
- Edit these as needed via the GitHub web interface (not via Gerrit or git).
- You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
- See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.
Message from Keith Randall:
Patch Set 6: Code-Review+2
(1 comment)
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from Keith Randall:
Patch Set 6: Code-Review+1
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from jub0bs:
Patch Set 6:
(1 comment)
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from Sean Liao:
Patch Set 6: Commit-Queue+1
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from Go LUCI:
Patch Set 6:
Dry run: CV is trying the patch.
Bot data: {"action":"start","triggered_at":"2025-08-31T11:35:53Z","revision":"1e65ba46e76f1330b662f44352901533e31e20fa"}
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from Sean Liao:
Patch Set 6: -Commit-Queue
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from Go LUCI:
Patch Set 6:
This CL has passed the run
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Message from Go LUCI:
Patch Set 6: LUCI-TryBot-Result+1
Please don’t reply on this GitHub thread. Visit golang.org/cl/699675.
After addressing review feedback, remember to publish your drafts!
Uh oh!
There was an error while loading. Please reload this page.
This change makes the fast path for ASCII characters inlineable in
DecodeRune and DecodeRuneInString and removes most instances of manual
inlining at call sites.
Here are some benchmark results (no change to allocations):
goos: darwin
goarch: amd64
pkg: unicode/utf8
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
│ old │ new │
│ sec/op │ sec/op vs base │
DecodeASCIIRune-8 2.4545n ± 2% 0.6253n ± 2% -74.52% (p=0.000 n=20)
DecodeJapaneseRune-8 3.988n ± 1% 4.023n ± 1% +0.86% (p=0.050 n=20)
DecodeASCIIRuneInString-8 2.4675n ± 1% 0.6264n ± 2% -74.61% (p=0.000 n=20)
DecodeJapaneseRuneInString-8 3.992n ± 1% 4.001n ± 1% ~ (p=0.625 n=20)
geomean 3.134n 1.585n -49.43%
Note: when #61502 gets resolved, DecodeRune and DecodeRuneInString should
be reverted to their idiomatic implementations.
Fixes #31666
Updates #48195