-
Notifications
You must be signed in to change notification settings - Fork 973
Description
[REQUIRED] Describe your environment
- Operating System version: docker - node alpine 12
- Browser version: n/a
- Firebase SDK version: 0.5.13
- Firebase Product: database (auth, database, storage, etc)
[REQUIRED] Describe the problem
When updating from @firebase/[email protected] to @firebase/[email protected] updates became very slow. We operate in a relatively high write environment, and are streaming state updates into firebase. When upgrading from 0.5.12 to 0.5.13 we began seeing not just slow downs, but issues with ack'ing messages to pub/sub. We tracked this down to a change in the @firebase/database library, specifically commit 86971ea. A change occurred in src/core/Repo.ts that added:
this.serverSyncTree_.calcCompleteEventCache(path)
to the Repo.update function. This update changed the time it took this loop:
each(childrenToMerge, (changedKey: string, changedValue: unknown) => {
empty = false;
const newNodeUnresolved = nodeFromJSON(changedValue);
changedChildren[changedKey] = resolveDeferredValueSnapshot(
newNodeUnresolved,
this.serverSyncTree_.calcCompleteEventCache(path),
serverValues
);
});
to complete from an average of 0ms to 750ms. This average of 750ms spans a range of about 5ms to upwards of 10,000ms. We believe this slowdown to be the cause of both our increase in observed update time, and our issues ack'ing message to pub/sub, since this piece of code seemingly never releases the event loop.
Steps to reproduce:
Write ~100 updates continuously as fast as you can, and track the time it takes to complete an update.