Improve performances of mutliple updates #3412
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When receiving a batch of realtime events, we used to treat them
sequentially and do the following:
This was highly inefficient, because the dispatch is a costful
operation, especially if the store is filled with documents and queries.
Indeed, each dispatch will trigger the full reevaluation of the existing
queries against the documents in the store.
So, to improve this behaviour we now introduce a debounce mechanism for
relatime events: we wait a fixed amount of time before processing the
events all at once.
To do this, each new realtime event is temporarily stored in a buffer,
and removed once treated.
This impact all treatments involving multiple realtime events, such as
trash, restore, or deletion from trash.
Note the debounce does not negatively affect single realtime events, as
we force the first event to be treated immediatly (and debounce only the
next ones if they occur less than 500ms after).
To show how impactful this is, we measured how long takes a folder to be
put in the trash. The folder contains 1K files.
=> This is a x87 improvements 🚀