Sync isolate: Use updatesSync #318
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.
In powersync-ja/sqlite_async.dart#105, we've fixed the updated stream to be based on synchronous udpate hooks behind the scenes, avoiding a growing async buffer for long-running writes that don't yield back to Dart.
Unfortunately, I've missed that the sync isolate uses a raw
CommonDatabase
and theupdates
stream, so the original issue is not actually fixed. This changes that toupdatesSync
. I've verified this with a one million item sync in the todolist sample (so there are also fts5 rows being created here). This reduces the amount of live update notifications from growing and reaching 2M+ items (old) to hovering from 0-60k before being GCed (new).I think a better fix would be to obtain a
sqlite_async
database instead of the underlying one, since that would eventually allow us to move to the update hook implementation in the core extension. But this seems like an obvious fix with little chance for regressions.