This page documents practical performance patterns for Mindwtr (desktop, mobile, and core).
High-Impact Areas
- Large list filtering and sorting
- Project/task ordering updates
- Sync merge and attachment reconciliation
- Re-render churn from broad store subscriptions
- SQLite query patterns (search, date filters, project/status views)
UI Rendering Guidance
- Prefer narrow store selectors and avoid selecting whole store objects.
- Group related selectors and memoize derived collections.
- Keep item components pure; push expensive transforms up to list-level memoization.
- Use virtualization for large lists and avoid dynamic height recalculation in hot paths.
- Avoid creating new inline callbacks/objects in large mapped lists.
Rendering Optimization Playbook
When a screen feels slow, use this order:
- Verify list item render count first (React DevTools profiler).
- Hoist static constants/styles out of render functions.
- Memoize heavy child components (
React.memo) with explicit prop equality where needed.
- Split large components by concern (header/form/list/modals) so state updates stay localized.
- Replace broad dependency arrays with smaller memoized selectors/helpers.
FlatList / Virtualization Tuning (Mobile)
- Set
initialNumToRender, maxToRenderPerBatch, windowSize intentionally by screen.
- Provide
getItemLayout where practical (fixed or measured fallback).
- Enable
removeClippedSubviews for larger lists.
- Keep
keyExtractor stable and avoid index keys.
- Avoid inline anonymous renderers in deeply nested item trees.
- Validate payload shape before merge to fail fast.
- Keep merge deterministic and O(n) over entity count (map by ID, avoid nested scans).
- Reconcile attachment metadata first; defer file IO/network to separate sync phase.
- Bound retries with backoff and classify retryable vs terminal errors.
- Cache backend config reads during a sync cycle to reduce repeated storage access.
Sync Tuning Tips
- Keep attachment upload/download concurrency conservative on mobile networks.
- Tune timeout and retry windows separately for metadata vs attachments.
- Abort quickly on offline transitions; avoid long retry chains after connectivity loss.
- Use progress instrumentation for long-running attachment phases.
- Track conflict count, max clock skew, and timestamp adjustments per sync run.
Sync Debug Checklist
If sync latency regresses:
- Compare local read, merge, remote write, and attachment phases separately.
- Verify rate-limit responses (
429) are not causing cascaded retries.
- Check attachment hash validation/retries for repeated failures.
- Confirm remote payload size and collection counts are within configured limits.
- Capture log samples with timestamps and request IDs around slow windows.
Database Guidance
- Use FTS indexes for free-text search where available.
- Keep common status/project/date filters indexed.
- Batch writes inside transactions for large imports/sync save paths.
- Keep JSON columns normalized at read boundaries and avoid repeated parse/stringify loops.
Profiling Checklist
- Reproduce with a realistic dataset (thousands of tasks, large projects).
- Measure before/after (render counts, query timings, sync duration).
- Check memory growth during long sessions.
- Verify no regressions in low-end devices/simulators.
- List interactions should remain responsive (<16ms frame budget where feasible).
- Search requests should be sub-100ms on typical local datasets.
- Sync merge should scale linearly with entity count.
- Avoid blocking UI threads with file/network operations.
- Add targeted tests when fixing regressions (render churn, merge complexity, retry behavior).
- Keep budget checks in CI for critical views and sync paths.
- Prefer small measurable improvements over broad speculative refactors.
- Re-profile after each optimization to verify real impact.