-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
perf: Reduce the size of row encoding UTF-8 #19911
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
performance
Performance issues or improvements
python
Related to Python Polars
rust
Related to Rust Polars
labels
Nov 21, 2024
9 tasks
coastalwhite
force-pushed
the
perf/re-small-utf8
branch
2 times, most recently
from
November 22, 2024 16:03
f22127a
to
da107d2
Compare
Before, row encoding and decoding would use the variable row encoding. Now, we use the fact that `0xFF` is always an invalid UTF-8 character. To encode, the string with bytes `b1, ..., bn` becomes `0x02, b1 + 1, ..., bn + 1, 0x00`. This way, we can just scan for the `0x00` when we want to know where to end. Empty strings are encoded as `0x01` and nulls as `0x00`. Everything is bitwise inverted for descending. This is always a size improvement and in particular saves massively for small strings. For example, encoding "a" went from 33 bytes to 3 bytes.
coastalwhite
force-pushed
the
perf/re-small-utf8
branch
from
November 23, 2024 14:51
da107d2
to
a9b143f
Compare
coastalwhite
requested review from
ritchie46,
c-peters,
alexander-beedie,
MarcoGorelli,
reswqa and
orlp
as code owners
November 23, 2024 14:52
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19911 +/- ##
==========================================
+ Coverage 79.44% 79.49% +0.04%
==========================================
Files 1555 1555
Lines 216140 216377 +237
Branches 2456 2456
==========================================
+ Hits 171716 172002 +286
+ Misses 43866 43817 -49
Partials 558 558 ☔ View full report in Codecov by Sentry. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
accepted
Ready for implementation
performance
Performance issues or improvements
python
Related to Python Polars
rust
Related to Rust Polars
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before, row encoding and decoding would use the variable row encoding. Now, we use the fact that
0xFF
is always an invalid UTF-8 character. To encode, the string with bytesb1, ..., bn
becomesb1 + 2, ..., bn + 2, 0x01
. This way, we can just scan for the0x01
when we want to know where to end. Nulls are encoded as0x00
. Everything is bitwise inverted for descending.This is always a size improvement and in particular saves massively for small strings. For example, encoding "a" went from 33 bytes to 2 bytes.
This is a continuation of #19874.