You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
changed the title
Switch to hashbrown (maybe behind a feature flag)
Allow for custom storage of attributes
Jul 22, 2023
IvanUkhov
changed the title
Allow for custom storage of attributes
Allow for custom storage of AttributesJul 22, 2023
It seems like internally,
Attributes
is astd::collections::HashMap
. Would it be possible to usehashbrown::HashMap
? Probably behind a Cargo flag to makehashbrown
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
usesahash
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 throughhashbrown
would provide the same results.The text was updated successfully, but these errors were encountered: