-
Notifications
You must be signed in to change notification settings - Fork 1.8k
perf: Improve performance of to_hex (> 2x)
#19503
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: main
Are you sure you want to change the base?
Conversation
to_hexto_hex by 2x
| ); | ||
| } | ||
| result.append_value(""); | ||
| let hex_str = value.to_hex(&mut buffer); |
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.
This could be made faster by handling the values separately from the nulls / avoiding the builder API.
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, it is even faster now! I updated the benchmark results in the PR description.
to_hex by 2xto_hex (> 2x)
| // Start with offset 0 | ||
| offsets.push(0); | ||
|
|
||
| // Process all values directly (including null slots - we write empty strings for nulls) |
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.
nit: I don't think this code is writing empty strings for nulls, it seems to process whatever value is in the null slot normally
Which issue does this PR close?
N/A
Rationale for this change
What changes are included in this PR?
Avoid string allocations and re-use a mutable buffer.
Are these changes tested?
Are there any user-facing changes?