museumsvictoria / spatial_audio_server

An audio backend for the multi-layered soundscape of Beyond Perception: Seeing the Unseen, a permanent exhibition at Scienceworks in Melbourne, Australia.
81 stars 14 forks source link

Speedup HashMap usage by switching to FxHasher #98

Closed mitchmindtree closed 6 years ago

mitchmindtree commented 6 years ago

Currently the audio server uses the std hashmap which is a cryptographically secure hash map. This kind of hashmap is more suitable to use with web servers - the provided security is overkill for the audio server and not worth the cost.

fxhash seems to provide a much faster hashing algorithm optimised for 32-64bit size keys, which is pretty much what we use exclusively throughout the audio server. If the hashmap begins showing up as a bottleneck in profiling this will likely be an easy solution.

mitchmindtree commented 6 years ago

Just came across the phf crate in a totally unrelated article - it looks like this crate provides tools for generating a custom hashmap type which optimises down into efficient lookup tables which would probably be a lot faster again. It does however look a little more complicated to setup, so it would be worth researching the limitations etc before diving in.