go
go copied to clipboard
time: optimize Parse and Time.Format for RFC3339
RFC3339 is the most common format to use (according to prior analysis, it accounts for 57% of formats; and that's only explicit calls to Format or Parse. It doesn't cover all the implicit cases that occur through MarshalText and UnmarshalText). We should optimize Parse and Time.Format to do a quick check for the RFC3339Nano or RFC3339 constants and hardcode the logic for that format. This would avoid the double parsing that currently occurs where we parse the format string to functionally run a virtual machine that then parses the input value.
cc @ianlancetaylor @rsc
Is it appropriate to offer my contribution here?
Sure, your contribution is welcomed. See https://go.dev/doc/contribute for how to contribute to Go. Thanks.
Happy to review.
Sure. thanks @dsnet @cherrymui
I’ll be back shortly with initial implementation.
Change https://go.dev/cl/421877 mentions this issue: time: optimize Format and Parse for RFC3339 and RFC3339Nano
Change https://go.dev/cl/425100 mentions this issue: time: add fuzz test for Time.appendFormatRFC3339
Change https://go.dev/cl/425197 mentions this issue: time: optimize Parse for RFC3339 and RFC3339Nano