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

proposal: use SmallVec instead of Vec for buffer #6

Open
swanandx opened this issue Mar 15, 2022 · 0 comments
Open

proposal: use SmallVec instead of Vec for buffer #6

swanandx opened this issue Mar 15, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@swanandx
Copy link
Owner

The idea is to use smallvec for buffer while extracting strings from file.
We only consider the strings which are longer than 4 characters, so for other strings, which we are going to reject anyway, we can avoid heap allocation caused due to buffer vector. here.

let mut buffer: SmallVec<[u8; 4]> = smallvec![]; // TODO: change 4 to more optimal number

So, what to do?

  • Change Vec to SmallVec
  • Experiment with different sizes ( at least 4 will be good imho, but we should try other using quasi-doubling strategy , i.e. 4, 8, 16, 32 )
  • Benchmark the code to see if it actually improves performance.
  • Choose the one with best performance. ( post the results here or while making PR )

It would be amazing if you can post benchmark of all sizes, then we can choose the most optimal.

@swanandx swanandx added the enhancement New feature or request label Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant