-
Notifications
You must be signed in to change notification settings - Fork 935
Speed up timestamptz decoding #338
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
|
I've included assertions as they are certainly necessary. This implementation runs in half the time with half as many allocations. Before this PR: Without assertions: After this PR: |
|
This looks good. It's unfortunate that this would lead to two very similar code paths for parsing time, but maybe that's worth it. My original code certainly wasn't optimized for performance. I'll merge this if there are no objections. (oh, and I checked Travis and it's the same tip / 9.4 issue as described in #334) |
|
How much can we speed up parseTs() if we avoid the second allocation? Where is it coming from in the first place? It's not obvious from just looking at the code. I'm a bit worried about having this much code to maintain just for parsing timestamps. |
Since parseTs() is used only for
Perhaps the conversion to string? This version operates on the byte slice. We also called out to
In general, or because I added a function instead of touching parseTs? I tried using time.Parse more heavily, but it was slower than parseTs.
Parsing other time-ish types is being debated in #329. I focused on |
|
I've added one more commit that I think makes this function easier to read. |
I don't mind not using time.Parse, but I wouldn't want two distinct hand-written routines for parsing time-related data. Naively thinking, we'd have one function which:
If we can make that function fast while supporting all three types, things ought to be pretty good. |
I agree. This PR should probably wait for a resolution to #329. |
Before:
After:
This expects the input to be correctly formatted from the backend and asserts nothing. I'm not sure how I feel about that... Thoughts?