-
Notifications
You must be signed in to change notification settings - Fork 18.4k
time: improve ParseDuration performance for invalid input #75531
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
time: improve ParseDuration performance for invalid input #75531
Conversation
This PR (HEAD: 2a8193e) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705195. Important tips:
|
Message from Alan Donovan: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from Emmanuel Odeke: Patch Set 1: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from Go LUCI: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-19T01:21:18Z","revision":"3076242a5428fd5aba8f81a5a2779f154db6481d"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from Emmanuel Odeke: Patch Set 1: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from Go LUCI: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from Go LUCI: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from kyose chang: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Add "parseDurationError" to reduce memory allocation in the error path of "ParseDuration" and delay the generation of error messages. This improves the performance when dealing with invalid input. The format of the error message remains unchanged. Benchmarks: │ old │ new │ │ sec/op │ sec/op vs base │ ParseDurationError-10 132.10n ± 4% 45.93n ± 2% -65.23% (p=0.000 n=10) │ old │ new │ │ B/op │ B/op vs base │ ParseDurationError-10 192.00 ± 0% 64.00 ± 0% -66.67% (p=0.000 n=10) │ old │ new │ │ allocs/op │ allocs/op vs base │ ParseDurationError-10 6.000 ± 0% 2.000 ± 0% -66.67% (p=0.000 n=10) Fixes golang#75521
2a8193e
to
7372739
Compare
This PR (HEAD: 7372739) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/705195. Important tips:
|
Message from Alan Donovan: Patch Set 2: Auto-Submit+1 Code-Review+2 Commit-Queue+1 (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from Go LUCI: Patch Set 2: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-09-19T14:38:00Z","revision":"228432391ce2469109583c2b1d7e8c40bd76f9b7"} Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Message from Alan Donovan: Patch Set 2: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
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/705195. |
Message from Go LUCI: Patch Set 2: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/705195. |
Add "parseDurationError" to reduce memory allocation in the error path of "ParseDuration" and delay the generation of error messages. This improves the performance when dealing with invalid input. The format of the error message remains unchanged. Benchmarks: │ old │ new │ │ sec/op │ sec/op vs base │ ParseDurationError-10 132.10n ± 4% 45.93n ± 2% -65.23% (p=0.000 n=10) │ old │ new │ │ B/op │ B/op vs base │ ParseDurationError-10 192.00 ± 0% 64.00 ± 0% -66.67% (p=0.000 n=10) │ old │ new │ │ allocs/op │ allocs/op vs base │ ParseDurationError-10 6.000 ± 0% 2.000 ± 0% -66.67% (p=0.000 n=10) Fixes #75521 Change-Id: I0dc9f28c9601b6be07b70d0a98613757d76e2c97 GitHub-Last-Rev: 7372739 GitHub-Pull-Request: #75531 Reviewed-on: https://go-review.googlesource.com/c/go/+/705195 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This PR is being closed because golang.org/cl/705195 has been merged. |
Add "parseDurationError" to reduce memory allocation in the error path of
"ParseDuration" and delay the generation of error messages. This improves
the performance when dealing with invalid input.
The format of the error message remains unchanged.
Benchmarks:
ParseDurationError-10 132.10n ± 4% 45.93n ± 2% -65.23% (p=0.000 n=10)
ParseDurationError-10 192.00 ± 0% 64.00 ± 0% -66.67% (p=0.000 n=10)
ParseDurationError-10 6.000 ± 0% 2.000 ± 0% -66.67% (p=0.000 n=10)
Fixes #75521