-
Notifications
You must be signed in to change notification settings - Fork 25
Optimize incremental sync: Phase 1 #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: bc5326c The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Remove queryBucketDescriptions(). Refactor logic to keep track of checksums per connection. Refactor BucketParameterQuerier implementation. Refactor watchWriteCheckpoint. Refactor bucket position tracking. For static updates, do diff of individual buckets if available. Start by always sending an invalidation event. Remove the need for fullDocument: 'updateLookup' for watching checkpoints. Move watchWriteCheckpoint to SyncRulesBucketStorage. We now always watch checkpoints per sync rules instance. Fix tests to use the new apis. Type fixes. Fix tests. Test storage on github actions.
5e745e3 to
2b024ff
Compare
6c02b7b to
5df24a0
Compare
Add more units tests.
We just let the SyncRulesBucketStorage instances get garbage collected - no need for active disposing of listeners. The lifecycle of SyncRulesBucketStorage is not well-defined, so active disposing could lead to more confusion down the line. BucketStorageFactory and BucketStorageBatch are still AsyncDisposable.
…imize-bucket-lookups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Havent tested anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've mostly looked at the sync changes, and they look good to me 👍
The base branch was changed.
This refactors large parts of the sync flow to allow better optimizations.
Refactoring:
watchWriteCheckpointis moved fromBucketStorageFactorytoSyncRulesBucketStorage, making it operate on a single sync-rules instance/version only. This simplifies the implementation and will make it much easier to do optimizations here, since we don't have to deal with sync rule changes.sync.ts, the bucket parameter state management is moved to a separate class, keeping the main loop simpler.The biggest actual optimization in this phase is removing
fullDocument: 'uploadLookup'from the changestream for watching checkpoints. Since this changeStream could be updated very frequently, this can add significant overhead on the bucket storage database. We now instead merge the incremental updates ourselves.Builds on some API refactoring in #192.
I added a new test-client command to test concurrent connections:
This just opens connections and keep them open to simulate sync load. No direct reporting of performance is done yet, but you can view the timestamp differences between the first
checkpoint_diffand the lastcheckpoint_completeoperations to get an idea of performance.