Skip to content

perf(sync2): export only what a linked sync can send and back up only merges that need it - #1626

Merged
A-EDev merged 3 commits into
mainfrom
perf/linked-sync-exports
Oct 31, 2026
Merged

A-EDev merged 3 commits into
mainfrom
perf/linked-sync-exports

Conversation

@A-EDev

@A-EDev A-EDev commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

On a phone with a large library, every linked sync exported the whole library to compare it with what was already sent, and a merge first wrote a full-profile backup. With another device playing that ran every 12 to 45 s; logcat showed 40 MB and 96 to 120 MB large-object bursts at each sync and 3 to 6 s backups, with the heap reaching 245 of 256 MB.

  • The pre-merge backup is taken only when a merge touches likes, settings, subscribed channels or a brain. Watch history, subscription groups, notes and playlists are written inside one Room transaction, which already undoes a failed merge.
  • A push exports only what can have changed: a brain once its 6-hour upload wait is over (it was exported every sync and then held back), a Room collection once Room's InvalidationTracker saw its tables change or while the ledger holds nothing of it (after a reset), every other collection as before. Skipped collections would have sent nothing.
  • The brain export writes straight into its stream instead of building a string and its bytes first.

Related issue

Refs #1412

Change type

  • Bug fix
  • Feature
  • Refactor or maintenance
  • Build, packaging, or CI
  • Documentation

Validation

  • ./gradlew :app:assembleGithubDebug: passed
  • ./gradlew :app:testGithubDebugUnitTest: 4717 tests, 0 failures (2 skipped), including the new PushPlanTest and the new ApplyOnceTest case
  • I ran any additional flavor-specific build or test tasks affected by this change: :app:compileFossDebugKotlin passed, ktlintCheck passed, python3 .github/scripts/nightly_notes.py --check passed
  • I manually tested the affected behavior on an Android device or emulator.

Test device and Android version:

Screenshots or recordings

Risk and compatibility

  • No Room schema change: one new read query on the linked-devices sent table.

  • What is uploaded and merged is unchanged; only when exports and backups run changes. A failed push marks its Room collections as changed again so the next push exports them.

  • Battery and memory: fewer exports and backups per sync. Not yet measured on a device.

  • The change does not introduce secrets, private data, or unexpected telemetry.

  • New user-facing text uses Android string resources.

  • Dependency and lockfile changes are intentional and limited to this PR.

  • Room schema changes include the required version bump and migration, or this PR does not change the Room schema.

  • Breaking changes and upgrade steps are clearly documented.

@github-actions github-actions Bot added documentation Improvements or additions to documentation algorithm Recommendation engine and math sync Device-to-device sync labels Oct 31, 2026
@A-EDev
A-EDev merged commit 65dccef into main Oct 31, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

algorithm Recommendation engine and math documentation Improvements or additions to documentation sync Device-to-device sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant