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

Allow for custom storage of Attributes #69

Open
tgross35 opened this issue Jul 21, 2023 · 1 comment
Open

Allow for custom storage of Attributes #69

tgross35 opened this issue Jul 21, 2023 · 1 comment

Comments

@tgross35
Copy link

It seems like internally, Attributes is a std::collections::HashMap. Would it be possible to use hashbrown::HashMap? Probably behind a Cargo flag to make hashbrown an optional dependency.

Reasoning: the HashMap in collections is extremely collision resistant (SipHash), but this means it is slower and has a larger per-entry memory overhead than alternatives. hashbrown uses ahash which is much faster and has a smaller per-entry overhead (1/8 the size if I recall correctly). ahash is not as collision resistant, but this is highly unlikely to be exploitable for this use case.

All the functions taking DefaultHasher would need to become generic.

Alternatively, using ahash directly without going through hashbrown would provide the same results.

@IvanUkhov
Copy link
Member

Thank you for the issue! In general, this crate strives to be minimalistic and independent, and adding dependencies would go against this philosophy. However, it would be appropriate to abstract away which struct is used for storing attributes via a trait so that one can implement that trait for anything else elsewhere.

@IvanUkhov IvanUkhov changed the title Switch to hashbrown (maybe behind a feature flag) Allow for custom storage of attributes Jul 22, 2023
@IvanUkhov IvanUkhov changed the title Allow for custom storage of attributes Allow for custom storage of Attributes Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants