perf: improve app performance with Web Worker for IndexedDB and faster selector memoization #11605
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.
Description
This PR delivers significant performance improvements for the ShapeShift web app across all browsers, with particularly impactful gains for Firefox users. The changes address three main bottlenecks: IndexedDB operations, redux-persist write frequency, and Redux selector memoization.
UAT:
Some jams of this branch (left) vs develop (right) on a simulated 4x CPU throttle:
Key Improvements
Web Worker for IndexedDB Operations
Redux-Persist Throttling
localStorage Migration for Small Slices
preferences,localWallet,gridplus,addressBookfast-deep-equal for Selector Memoization
lodash/isEqualwithfast-deep-equalincreateDeepEqualOutputSelectorPerformance Profiling Infrastructure (dev-only)
VITE_FEATURE_PERFORMANCE_PROFILERflagPerformance Metrics
User Experience: UI Responsiveness
The main improvement is eliminating "jank" (UI freezing) caused by IndexedDB operations blocking the main thread.
These freezes occurred in chunks (e.g., 50-200ms at a time) causing stuttering, dropped frames, and unresponsive buttons/inputs.
Page Load: Time to Interactive
Ongoing Responsiveness: State Persistence
When you interact with the app (change settings, get quotes, etc.), state is saved to IndexedDB. Previously this caused micro-freezes.
Selector Performance (fast-deep-equal)
This reduces CPU time spent comparing Redux state, making all UI updates snappier.
Trade-offs
Why Firefox Benefits Most
Chrome's IndexedDB is highly optimized and rarely blocks for long. Firefox's IndexedDB is significantly slower - operations that take 2ms in Chrome can take 50-200ms in Firefox. By moving these operations to a Web Worker, Firefox users see the biggest improvement: from a janky, freezing experience to a smooth, responsive app.
How to Verify
Quick test: Open the app in Firefox on develop branch, then on this branch. Notice:
DevTools test:
Issue (if applicable)
N/A - Performance improvement initiative
Risk
Low-Medium Risk - These changes affect core state persistence and selector infrastructure, but:
All wallet connections and state persistence. The
actionslice (pending swaps, limit orders, bridge claims) remains persisted via IndexedDB/Worker to ensure user notifications survive page refresh.Testing
Engineering
To test locally:
yarn devand open in browserVITE_FEATURE_PERFORMANCE_PROFILER=truein.env.developmentVerification checklist:
yarn type-checkpassesyarn lintpassesyarn testpassesOperations
The performance profiler is behind
VITE_FEATURE_PERFORMANCE_PROFILERflag (disabled in production). All other changes are infrastructure improvements that don't change user-facing behavior.Functional testing:
Screenshots (if applicable)
Performance Profiler Overlay (dev-only):
🤖 Generated with Claude Code