-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: improve performance of C implementation #43
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #43 +/- ##
===========================================
+ Coverage 95.74% 100.00% +4.25%
===========================================
Files 2 2
Lines 47 52 +5
Branches 4 5 +1
===========================================
+ Hits 45 52 +7
+ Misses 2 0 -2 ☔ View full report in Codecov by Sentry. |
This improves the performance of the C implementation by eschewing C++ string allocations and trying to make sure the Cython code does as little copying and unnecessary non-ASCII decoding as possible.
Buffer sizes all look right. |
pushed on production system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @akx
Nice work!
This PR:
std::string
allocations in favor of simple byte buffers and trying to make sure the Cython code does as little copying and unnecessary non-ASCII decoding as possible.Caution
I tried to be extra fastidious and careful about the use of raw buffers here, but it's likely a good idea to look over this with a pretty fine comb.
On my machine, this seems to improve performance approximately thus:
ulid_now_bytes
: 1,439 OPS -> 1,757 OPS (+22%)ulid_hex
: 1,057 OPS -> 1,414 OPS (+33%)ut_decode
: 8,862 OPS -> 12,660 OPS (+42%)ulid_at_time
: 5,879 OPS -> 6,390 OPS (+9%)ulid_now
: 5,972 -> 6,189 OPS (+3%)The new timestamp parsing API is also pretty snappy: