Skip to content

Optimize / Storage migrations#2491

Merged
sonytooo merged 1 commit into
v2from
optimize/storage-migrations
Jun 18, 2026
Merged

Optimize / Storage migrations#2491
sonytooo merged 1 commit into
v2from
optimize/storage-migrations

Conversation

@sonytooo

Copy link
Copy Markdown
Member

Optimize storage migration sweep

StorageController ran 20 migrations on every boot, and since get/set/remove all block on that sweep, it held up app load (especially on mobile, where each storage call is a postMessage round-trip to native RN storage).

Each migration re-read passedMigrations and read its data keys before checking whether it had already run. In the steady state (returning user, everything already migrated) this meant ~41 reads + ~3 writes on every single launch.

Changes

  • Read passedMigrations once into an in-memory Set; every migration now checks it first and returns before touching storage.
  • passedMigrations is written only when a migration actually does work (#markMigrationPassed).
  • Added missing guards to 4 migrations that previously ran (and 2 that wrote) on every boot.

No behavioral change - each migration performs the same transformation under the same conditions; only redundant I/O was removed.

Result

Steady-state boot: ~44 storage requests -> 1 (~97% fewer).

Tests

Added migration sweep performance tests asserting a fully-migrated install does 1 read / 0 writes, and that the newly-guarded migrations don't re-run.

@PetromirDev PetromirDev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@sonytooo sonytooo merged commit 860904b into v2 Jun 18, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants