Mailspring/internal_packages/search-index/lib/main.es6
Mark Hahnenberg 781080716c [search-index] Throttle search indexing
Summary:
This diff adds a new SearchIndexer class that each of the concrete
indexer implementations register with. This new class uses the
`isSearchIndexed` field in searchable classes to split indexing work
into chunks. It then times how long it takes to index each chunk and
schedules more work based on a target CPU percent. For example, if it
takes 150 ms to index the last chunk of work and the target CPU fraction
is 0.05 (i.e. 5% CPU use) then it will schedule the next increment of
indexing 3 seconds in the future.

Test Plan: Run locally, verify that indexing occurs in increments

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3707
2017-01-16 10:32:45 -08:00

19 lines
652 B
JavaScript

import ThreadSearchIndexStore from './thread-search-index-store'
import ContactSearchIndexer from './contact-search-indexer'
// import EventSearchIndexer from './event-search-indexer'
import SearchIndexer from './search-indexer'
export function activate() {
const indexer = new SearchIndexer()
ThreadSearchIndexStore.activate(indexer)
ContactSearchIndexer.activate(indexer)
// TODO Calendar feature has been punted, we will disable this indexer for now
// EventSearchIndexer.activate(indexer)
}
export function deactivate() {
ThreadSearchIndexStore.deactivate()
ContactSearchIndexer.deactivate()
// EventSearchIndexer.deactivate()
}