The branch used can be found at: https://github.com/jmcanterafonseca/gaia/tree/contact_indexing_suffix_array The application used is 'ContactsManager'. First it is needed to load and index a set of 500 contacts. That process can take time. Automatically it will be generated 2 indexes: * a regular suffix array, based in memory. That index can be persisted to a datastore and to a JSON object stored on the SDCard. ('Persist' button) * a indexedDB based suffix array Findings: The indexedDB search is around 10-15 times slower than the in-memory search. In-memory search is taking around tens of milisecs to resolve a search query whereareas indexedDB one is taking hundreds of milisecs. The indexedDB-based index is occupying > 4 Mb in disk. Further optimizations might be done. Once the in-memory based index is loaded, the RSS of the app augments in around 15Mb. The search can be done using both indexes. For certain queries the results can be a bit different as the searching algorithms vary and we are setting a limit for the first 10 results.
Latest update: The above branch includes an experimental hybrid solution which allow us to use the best of both worlds: https://github.com/jmcanterafonseca/gaia/tree/contacts_search_improved SuffixArray supported by indexedDB. Using this approach we have two advantages: 1/ For 2000 Contacts the indexedDB is only occupying around 4 Mbs 2/ The RSS of the app does not raise so much as we only load in memory the corresponding chunk (based on the start letter) of the suffixArray I believe search times can be improved but that can be done in another iteration.