Skip to content
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: bit optimization #3

Merged
merged 10 commits into from
Feb 26, 2024
Merged

feat: bit optimization #3

merged 10 commits into from
Feb 26, 2024

Conversation

is-it-ayush
Copy link
Owner

@is-it-ayush is-it-ayush commented Feb 26, 2024

the problem.

Currently our token are 8 bits (u8) in length. The thing is, we only have 8 tokens and this perfectly fits into 3 bits. We can substantially reduce the size of the encoded data by migrating from 8 bit tokens to 3 bit tokens.

so what.

The PR switched from 8 bit tokens to 3 bit tokens.

gotchas.

  • We gotta be extra careful around String and Bytes since the only way to decode them is to march forward on them. The problem is when marching forward you could encounter string bits that can resemble token bits causing you to exit early. The only workaround that works for this is to use fixed length tokens in the 8 bit space. Hence for strings and bytes. We return back to 8 bit space.

before.

image

after.

image

@is-it-ayush is-it-ayush marked this pull request as ready for review February 26, 2024 15:10
@is-it-ayush is-it-ayush changed the base branch from master to 1.0.0 February 26, 2024 15:16
@is-it-ayush is-it-ayush merged commit 7b76adb into 1.0.0 Feb 26, 2024
8 checks passed
@is-it-ayush is-it-ayush deleted the ayu/bitvec_optimization branch February 28, 2024 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant