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

Consider not using SmallVec #4

Open
Imberflur opened this issue Mar 25, 2022 · 1 comment
Open

Consider not using SmallVec #4

Imberflur opened this issue Mar 25, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@Imberflur
Copy link

Imberflur commented Mar 25, 2022

Because SmallVec has the capability to store elements inline for small lengths it has to make additional checks on whether an allocation or inline storage is being used. This introduces some overhead as evidenced in benchmarks.

In the use cases where I want to reach for a bitvec crate I typically expect to need to represent larger amount of bits than will fit inline in a SmallVec. So the allocation savings may not be significant enough to be worth this additional overhead.

I think it would be useful to consider replacing SmallVec with a plain Vec or making BitVecSimd generic over the backing storage.

@GCCFeli GCCFeli self-assigned this Mar 28, 2022
@GCCFeli GCCFeli added the enhancement New feature or request label Mar 28, 2022
@lorenzleutgeb
Copy link

I think that's a good point. However, I'd advocate for the generic solution. I have two slightly different use-cases. For both of them, the maximum size is not known at compile time, but in one case the maximum size is known at runtime, when initialize my data structure.

In the case where I know the maximum size, and I know that it is smaller than a certain multiple of machine words, I'd use a BitVec that lives on the stack. In the other case I'd use a BitVec that in turn uses SmallVec to allocate as necessary.

Users that are only interested in a "larger amount of bits" could use an implementation based on Vec.

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

3 participants