-
Notifications
You must be signed in to change notification settings - Fork 18k
time: improve performance of calendar algorithms and clarify its spec… #64600
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
base: master
Are you sure you want to change the base?
Conversation
…ification This implementation improves the performance of Go's time package using the recent algorithms developed by Neri and Schneider [1]. Their algorithms are faster than alternatives, my benchmarks confirm performance improvements in Go as well. ``` goos: linux goarch: amd64 pkg: time cpu: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz | /tmp/master.txt | /tmp/nerishcneider.txt | sec/op | sec/op vs base Now-8 69.38n ± 0% 69.33n ± 0% -0.07% (p=0.001 n=20) NowUnixNano-8 70.35n ± 0% 70.08n ± 0% -0.38% (p=0.000 n=20) NowUnixMilli-8 71.47n ± 0% 71.26n ± 0% -0.30% (p=0.000 n=20) NowUnixMicro-8 71.32n ± 0% 71.21n ± 0% -0.15% (p=0.000 n=20) Format-8 441.9n ± 0% 433.8n ± 0% -1.83% (p=0.000 n=20) FormatRFC3339-8 293.9n ± 0% 283.4n ± 0% -3.57% (p=0.000 n=20) FormatRFC3339Nano-8 297.5n ± 0% 286.9n ± 0% -3.55% (p=0.000 n=20) FormatNow-8 242.4n ± 0% 239.7n ± 0% -1.11% (p=0.000 n=20) MarshalJSON-8 144.0n ± 0% 136.2n ± 0% -5.42% (p=0.000 n=20) MarshalText-8 142.0n ± 0% 136.2n ± 0% -4.02% (p=0.000 n=20) Parse-8 241.2n ± 0% 240.9n ± 0% -0.12% (p=0.002 n=20) ParseRFC3339UTC-8 78.52n ± 0% 73.12n ± 0% -6.87% (p=0.000 n=20) ParseRFC3339UTCBytes-8 86.60n ± 0% 81.05n ± 0% -6.42% (p=0.000 n=20) ParseRFC3339TZ-8 291.5n ± 0% 283.1n ± 0% -2.90% (p=0.000 n=20) ParseRFC3339TZBytes-8 343.2n ± 0% 333.2n ± 0% -2.93% (p=0.000 n=20) ParseDuration-8 125.6n ± 0% 125.8n ± 0% +0.16% (p=0.002 n=20) Hour-8 6.458n ± 0% 6.457n ± 0% ~ (p=0.130 n=20) Second-8 6.460n ± 0% 6.456n ± 0% -0.05% (p=0.002 n=20) Year-8 18.68n ± 0% 14.10n ± 0% -24.52% (p=0.000 n=20) Day-8 24.01n ± 0% 17.14n ± 0% -28.61% (p=0.000 n=20) ISOWeek-8 27.55n ± 0% 24.46n ± 0% -11.22% (p=0.000 n=20) GoString-8 157.9n ± 0% 152.9n ± 0% -3.13% (p=0.000 n=20) UnmarshalText-8 290.1n ± 0% 283.4n ± 0% -2.31% (p=0.000 n=20) Geomean 93.84n ± 0% 89.08n ± 0% -5.07% ``` To achieve better performance we should change the supported range of dates: instead of supporting years taking any int value, they should be restricted to a much smaller range which still spans tens of thousands of years. [1] Neri, C, Schneider, L. Euclidean affine functions and their application to calendar algorithms. Softw Pract Exper. 2023; 53(4): 937–970. doi:10.1002/spe.3172 https://onlinelibrary.wiley.com/doi/full/10.1002/spe.3172 For: golang#63844
This PR (HEAD: 6d98312) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/548155. Important tips:
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/548155. |
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/548155. |
Message from [email protected]: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/548155. |
Message from Vadim Vygonets: Patch Set 1: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/548155. |
Message from Alexander Yastrebov: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/548155. |
This PR (HEAD: 59ed4dd) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/548155. Important tips:
|
This implementation improves the performance of Go's time package using the recent algorithms developed by Neri and Schneider [1]. Their algorithms are faster than alternatives, my benchmarks confirm performance improvements in Go as well.
To achieve better performance we should change the supported range of dates: instead of supporting years taking any int value, they should be restricted to a much smaller range which still spans tens of thousands of years.
[1] Neri, C, Schneider, L. Euclidean affine functions and their application to calendar algorithms. Softw Pract Exper. 2023; 53(4): 937–970. doi:10.1002/spe.3172 https://onlinelibrary.wiley.com/doi/full/10.1002/spe.3172
For: #63844