hinto-janai/festival

Pre-compute `Collection`-related `Search` keys

Closed this issue · 1 comments

What

Search currently starts with a cache of 0 keys, and only acquires them as the user sends input.

We already have a bunch of String's of the user's music data and could pre-compute some search Keychain's with them.

Pros

  • All user-related data will already be cached; their data in particular will have fast response times

Cons

  • More memory usage
  • Search may lag behind after the Collection creation depending on how long and how many Keychain's we make

Potential workarounds

This could be combined with #10 and a new "Search cache" phase could be introduced in the CCD process, with maybe even the resulting HashMap being embedded within the Collection itself.

The process can also easily be run in parallel:

  1. .chunk() on the keys, spawn threads
  2. Run search algo
  3. Either lock and push with Mutex or
  4. Join and flatten each thread's individual results

Search is now much faster, this is no longer needed.