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

Add a medium length string mode #93

Merged
merged 5 commits into from
Nov 3, 2023
Merged

Conversation

ngoldbaum
Copy link
Member

@ngoldbaum ngoldbaum commented Nov 1, 2023

This adds a "medium string" mode where the sizes of arena allocations are stored using a char instead of a size_t, saving 8 bytes per string for strings with lengths between 16 and 255 bytes. I modified the tests so they use longer strings more often which exercises all the different memory allocation modes we're now supporting.

I also dropped the attempt to store the size_t sizes in aligned locations because it adds a bunch of bookkeeping headaches. If it turns out the memcpy to unaligned addresses is slow we can come back to this.

@ngoldbaum ngoldbaum changed the title Slim memory usage Add a medium length string mode Nov 1, 2023
@ngoldbaum
Copy link
Member Author

I'm glad I have ASAN running in the tests here, it noticed a serious flaw in the first version of this.

@ngoldbaum ngoldbaum merged commit e663f0f into numpy:main Nov 3, 2023
1 check passed
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.

1 participant