-
Notifications
You must be signed in to change notification settings - Fork 303
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
message: optimize lookupAndFormat function for better performance #51
Conversation
This commit optimizes the lookupAndFormat function to reduce code redundancy and improve performance. Benchmarks show a significant performance increase across various Sprintf and Fprint functions. benchstat old.txt new.txt goos: darwin goarch: arm64 pkg: golang.org/x/text/message │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ SprintfPadding-12 333.0n ± 1% 216.0n ± 1% -35.15% (p=0.000 n=10) SprintfEmpty-12 307.3n ± 1% 170.9n ± 1% -44.38% (p=0.000 n=10) SprintfString-12 313.5n ± 1% 178.9n ± 2% -42.91% (p=0.000 n=10) SprintfTruncateString-12 315.6n ± 1% 182.3n ± 2% -42.23% (p=0.000 n=10) SprintfQuoteString-12 320.1n ± 0% 198.6n ± 1% -37.96% (p=0.000 n=10) SprintfInt-12 325.0n ± 1% 203.1n ± 1% -37.51% (p=0.000 n=10) SprintfIntInt-12 340.2n ± 1% 233.2n ± 2% -31.47% (p=0.000 n=10) SprintfPrefixedInt-12 335.2n ± 1% 226.2n ± 1% -32.54% (p=0.000 n=10) SprintfFloat-12 330.1n ± 1% 209.7n ± 1% -36.48% (p=0.000 n=10) SprintfComplex-12 365.1n ± 1% 276.0n ± 2% -24.41% (p=0.000 n=10) SprintfBoolean-12 311.8n ± 0% 178.6n ± 3% -42.72% (p=0.000 n=10) SprintfHexString-12 328.1n ± 1% 204.8n ± 2% -37.56% (p=0.000 n=10) SprintfHexBytes-12 334.0n ± 2% 216.4n ± 1% -35.20% (p=0.000 n=10) SprintfBytes-12 340.8n ± 7% 213.9n ± 1% -37.25% (p=0.000 n=10) SprintfStringer-12 662.5n ± 3% 453.2n ± 1% -31.59% (p=0.000 n=10) SprintfStructure-12 373.8n ± 6% 275.7n ± 1% -26.23% (p=0.000 n=10) ManyArgs-12 485.1n ± 4% 425.4n ± 1% -12.30% (p=0.000 n=10) FprintInt-12 265.8n ± 2% 262.0n ± 1% -1.41% (p=0.011 n=10) FprintfBytes-12 348.4n ± 1% 258.8n ± 1% -25.70% (p=0.000 n=10) FprintIntNoAlloc-12 262.0n ± 2% 261.2n ± 2% ~ (p=0.565 n=10) geomean 342.4n 233.7n -31.75%
This PR (HEAD: 904d624) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/text/+/584095. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Zhen Li: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Marcel van Lohuizen: Patch Set 1: Code-Review+2 Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Ian Lance Taylor: Patch Set 1: Auto-Submit+1 Code-Review+1 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Go LUCI: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2024-05-14T16:42:47Z","revision":"3835a8599bf1e9924fb3a7362b0b94e6632dd2d1"} Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Ian Lance Taylor: Patch Set 1: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Go LUCI: Patch Set 1: This CL has failed the run. Reason: Tryjob golang/try/x_text-gotip-linux-arm64 has failed with summary (view all results): FAILURE
Error: Links: Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Go LUCI: Patch Set 1: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Ian Lance Taylor: Patch Set 2: Auto-Submit+1 Code-Review+1 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Go LUCI: Patch Set 2: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2024-05-14T16:46:10Z","revision":"d61b514ea0cd60441ad558b5e2ddbe072d3b53d5"} Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Ian Lance Taylor: Patch Set 2: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Go LUCI: Patch Set 2: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
Message from Go LUCI: Patch Set 2: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/584095. |
This commit optimizes the lookupAndFormat function to reduce code redundancy and improve performance. Benchmarks show a significant performance increase across various Sprintf and Fprint functions. benchstat old.txt new.txt goos: darwin goarch: arm64 pkg: golang.org/x/text/message │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ SprintfPadding-12 333.0n ± 1% 216.0n ± 1% -35.15% (p=0.000 n=10) SprintfEmpty-12 307.3n ± 1% 170.9n ± 1% -44.38% (p=0.000 n=10) SprintfString-12 313.5n ± 1% 178.9n ± 2% -42.91% (p=0.000 n=10) SprintfTruncateString-12 315.6n ± 1% 182.3n ± 2% -42.23% (p=0.000 n=10) SprintfQuoteString-12 320.1n ± 0% 198.6n ± 1% -37.96% (p=0.000 n=10) SprintfInt-12 325.0n ± 1% 203.1n ± 1% -37.51% (p=0.000 n=10) SprintfIntInt-12 340.2n ± 1% 233.2n ± 2% -31.47% (p=0.000 n=10) SprintfPrefixedInt-12 335.2n ± 1% 226.2n ± 1% -32.54% (p=0.000 n=10) SprintfFloat-12 330.1n ± 1% 209.7n ± 1% -36.48% (p=0.000 n=10) SprintfComplex-12 365.1n ± 1% 276.0n ± 2% -24.41% (p=0.000 n=10) SprintfBoolean-12 311.8n ± 0% 178.6n ± 3% -42.72% (p=0.000 n=10) SprintfHexString-12 328.1n ± 1% 204.8n ± 2% -37.56% (p=0.000 n=10) SprintfHexBytes-12 334.0n ± 2% 216.4n ± 1% -35.20% (p=0.000 n=10) SprintfBytes-12 340.8n ± 7% 213.9n ± 1% -37.25% (p=0.000 n=10) SprintfStringer-12 662.5n ± 3% 453.2n ± 1% -31.59% (p=0.000 n=10) SprintfStructure-12 373.8n ± 6% 275.7n ± 1% -26.23% (p=0.000 n=10) ManyArgs-12 485.1n ± 4% 425.4n ± 1% -12.30% (p=0.000 n=10) FprintInt-12 265.8n ± 2% 262.0n ± 1% -1.41% (p=0.011 n=10) FprintfBytes-12 348.4n ± 1% 258.8n ± 1% -25.70% (p=0.000 n=10) FprintIntNoAlloc-12 262.0n ± 2% 261.2n ± 2% ~ (p=0.565 n=10) geomean 342.4n 233.7n -31.75% Change-Id: Id9999469f3fd0ca0290a5cb81f42fff81277b451 GitHub-Last-Rev: 904d624 GitHub-Pull-Request: #51 Reviewed-on: https://go-review.googlesource.com/c/text/+/584095 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
This PR is being closed because golang.org/cl/584095 has been merged. |
This commit optimizes the lookupAndFormat function to reduce code redundancy
and improve performance. Benchmarks show a significant performance increase
across various Sprintf and Fprint functions.
benchstat old.txt new.txt
goos: darwin
goarch: arm64
pkg: golang.org/x/text/message
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
SprintfPadding-12 333.0n ± 1% 216.0n ± 1% -35.15% (p=0.000 n=10)
SprintfEmpty-12 307.3n ± 1% 170.9n ± 1% -44.38% (p=0.000 n=10)
SprintfString-12 313.5n ± 1% 178.9n ± 2% -42.91% (p=0.000 n=10)
SprintfTruncateString-12 315.6n ± 1% 182.3n ± 2% -42.23% (p=0.000 n=10)
SprintfQuoteString-12 320.1n ± 0% 198.6n ± 1% -37.96% (p=0.000 n=10)
SprintfInt-12 325.0n ± 1% 203.1n ± 1% -37.51% (p=0.000 n=10)
SprintfIntInt-12 340.2n ± 1% 233.2n ± 2% -31.47% (p=0.000 n=10)
SprintfPrefixedInt-12 335.2n ± 1% 226.2n ± 1% -32.54% (p=0.000 n=10)
SprintfFloat-12 330.1n ± 1% 209.7n ± 1% -36.48% (p=0.000 n=10)
SprintfComplex-12 365.1n ± 1% 276.0n ± 2% -24.41% (p=0.000 n=10)
SprintfBoolean-12 311.8n ± 0% 178.6n ± 3% -42.72% (p=0.000 n=10)
SprintfHexString-12 328.1n ± 1% 204.8n ± 2% -37.56% (p=0.000 n=10)
SprintfHexBytes-12 334.0n ± 2% 216.4n ± 1% -35.20% (p=0.000 n=10)
SprintfBytes-12 340.8n ± 7% 213.9n ± 1% -37.25% (p=0.000 n=10)
SprintfStringer-12 662.5n ± 3% 453.2n ± 1% -31.59% (p=0.000 n=10)
SprintfStructure-12 373.8n ± 6% 275.7n ± 1% -26.23% (p=0.000 n=10)
ManyArgs-12 485.1n ± 4% 425.4n ± 1% -12.30% (p=0.000 n=10)
FprintInt-12 265.8n ± 2% 262.0n ± 1% -1.41% (p=0.011 n=10)
FprintfBytes-12 348.4n ± 1% 258.8n ± 1% -25.70% (p=0.000 n=10)
FprintIntNoAlloc-12 262.0n ± 2% 261.2n ± 2% ~ (p=0.565 n=10)
geomean 342.4n 233.7n -31.75%