-
Notifications
You must be signed in to change notification settings - Fork 149
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
feat(sync-service): Encode JSON encode on write rather than read #1485
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for electric-next canceled.
|
robacourt
force-pushed
the
rob/json-encode-on-write
branch
from
August 7, 2024 07:57
62c172f
to
2d8f95e
Compare
robacourt
force-pushed
the
rob/json-encode-on-write
branch
from
August 7, 2024 08:43
96e059e
to
e72d7c3
Compare
alco
reviewed
Aug 7, 2024
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 have reviewed the first commit.
Will take a separate look at the refactoring and get back to you.
packages/sync-service/test/electric/shape_cache/storage_implementations_test.exs
Outdated
Show resolved
Hide resolved
packages/sync-service/test/electric/shape_cache/storage_implementations_test.exs
Outdated
Show resolved
Hide resolved
packages/sync-service/test/electric/shape_cache/storage_implementations_test.exs
Outdated
Show resolved
Hide resolved
alco
approved these changes
Aug 7, 2024
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.
Brilliant! 💎
robacourt
force-pushed
the
rob/json-encode-on-write
branch
from
August 7, 2024 09:10
967a969
to
e9e8a2c
Compare
robacourt
force-pushed
the
rob/json-encode-on-write
branch
from
August 7, 2024 09:11
e9e8a2c
to
22d5f96
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
JSON encoding on write rather than read to reduce memory footprint. For example the memory use of an initial sync of a 35MB/200k row table can be reduced from 50MB to 25MB on the first initial sync (which includes the encoding and the writing to storage) and to 6MB on subsequent initial syncs (where we just read from storage and there's no encoding).
This change also allows some simplifications, so I have included them as refactoring in this PR:
LogItems
prepared_change
intermediate state has been removed. The transformationChanges > list(prepared_change) > LogItems
now is simplyChanges > LogItems
which makes the code more readable (prepared_change
was a 5 tuple rather than a nicely labeled map) and easier to reason about (since there's one less data structure to worry about)Shapes.Querying
that creates it andLogItems.from_snapshot_row/4
that reads it.I've rebased this PR into 2 commits, the functional change and the refactoring, to aid with reviewing.