docs(31-01): complete selector optimization plan
Tasks completed: 2/2 - Create composed selectors in mixersSlice.js - Refactor useMixerHelper to use composed selectors SUMMARY: .planning/phases/31-selector-optimization/31-01-SUMMARY.md
This commit is contained in:
parent
43b99c549d
commit
20ab1fd86a
|
|
@ -10,11 +10,11 @@ See: .planning/PROJECT.md (updated 2026-03-03)
|
||||||
## Current Position
|
## Current Position
|
||||||
|
|
||||||
Phase: 31 of 32 (Selector Optimization)
|
Phase: 31 of 32 (Selector Optimization)
|
||||||
Plan: Not started
|
Plan: 1 of 1 complete
|
||||||
Status: Ready to plan
|
Status: Phase complete
|
||||||
Last activity: 2026-03-05 — Completed Phase 30 Component Memoization
|
Last activity: 2026-03-05 — Completed 31-01-PLAN.md (Selector Optimization)
|
||||||
|
|
||||||
Progress: [██████░░░░] 60%
|
Progress: [███████░░░] 70%
|
||||||
|
|
||||||
## Performance Metrics
|
## Performance Metrics
|
||||||
|
|
||||||
|
|
@ -25,9 +25,9 @@ Progress: [██████░░░░] 60%
|
||||||
|
|
||||||
**v1.7 Performance Optimization (In Progress):**
|
**v1.7 Performance Optimization (In Progress):**
|
||||||
- Phases: 5 (phases 28-32)
|
- Phases: 5 (phases 28-32)
|
||||||
- Phases completed: 3 (Phases 28, 29, 30)
|
- Phases completed: 4 (Phases 28, 29, 30, 31)
|
||||||
- Requirements: 19 (10 complete)
|
- Requirements: 19 (11 complete)
|
||||||
- Plans completed: 4
|
- Plans completed: 5
|
||||||
|
|
||||||
## Accumulated Context
|
## Accumulated Context
|
||||||
|
|
||||||
|
|
@ -52,24 +52,26 @@ Recent decisions (v1.7):
|
||||||
- React.memo on consumers completes the optimization chain - 29-01
|
- React.memo on consumers completes the optimization chain - 29-01
|
||||||
- Container component memoization completes memoization chain from Phase 29 - 30-01
|
- Container component memoization completes memoization chain from Phase 29 - 30-01
|
||||||
- Default shallow comparison sufficient when props are stable from upstream - 30-01
|
- Default shallow comparison sufficient when props are stable from upstream - 30-01
|
||||||
|
- Group selectors by usage pattern (core, track, lookup, metadata) - 31-01
|
||||||
|
- shallowEqual with composed selectors for object return comparisons - 31-01
|
||||||
|
|
||||||
### Investigation Findings (v1.7)
|
### Investigation Findings (v1.7)
|
||||||
|
|
||||||
**Root causes of page freezes:**
|
**Root causes of page freezes:**
|
||||||
1. VU meter updates at 50-70/sec through Redux
|
1. VU meter updates at 50-70/sec through Redux - FIXED (Phase 28)
|
||||||
2. MixersContext creates new reference every render
|
2. MixersContext creates new reference every render - FIXED (Phase 29)
|
||||||
3. 18+ individual selectors in useMixerHelper
|
3. 18+ individual selectors in useMixerHelper - FIXED (Phase 31)
|
||||||
4. Triple track sync calls on session join
|
4. Triple track sync calls on session join
|
||||||
5. Debounce instance recreation on dependency change
|
5. Debounce instance recreation on dependency change
|
||||||
6. Missing React.memo on child components
|
6. Missing React.memo on child components - FIXED (Phase 30)
|
||||||
|
|
||||||
**Hotspot files:**
|
**Hotspot files:**
|
||||||
- `useMixerStore.js:178-185` - VU update dispatch
|
- `useMixerStore.js:178-185` - VU update dispatch - FIXED
|
||||||
- `useVuHelpers.js:99-104` - setVuStates object creation
|
- `useVuHelpers.js:99-104` - setVuStates object creation - FIXED
|
||||||
- `mixersSlice.js:145-165` - updateMixer creates new objects
|
- `mixersSlice.js:145-165` - updateMixer creates new objects
|
||||||
- `JKSessionScreen.js:463-475` - Triple track sync calls
|
- `JKSessionScreen.js:463-475` - Triple track sync calls
|
||||||
- `useSessionModel.js:605-614` - Debounced trackChanges
|
- `useSessionModel.js:605-614` - Debounced trackChanges
|
||||||
- `MixersContext.js:10` - Unmemoized context value
|
- `MixersContext.js:10` - Unmemoized context value - FIXED
|
||||||
|
|
||||||
### Deferred Issues
|
### Deferred Issues
|
||||||
|
|
||||||
|
|
@ -95,8 +97,8 @@ Recent decisions (v1.7):
|
||||||
## Session Continuity
|
## Session Continuity
|
||||||
|
|
||||||
Last session: 2026-03-05
|
Last session: 2026-03-05
|
||||||
Stopped at: Completed Phase 30 Component Memoization
|
Stopped at: Completed 31-01-PLAN.md (Selector Optimization)
|
||||||
Resume file: None
|
Resume file: None
|
||||||
|
|
||||||
**Next steps:**
|
**Next steps:**
|
||||||
1. `/gsd:plan-phase 31` — plan Selector Optimization phase
|
1. `/gsd:plan-phase 32` — plan final verification/performance testing phase
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
---
|
||||||
|
phase: 31-selector-optimization
|
||||||
|
plan: 01
|
||||||
|
subsystem: performance
|
||||||
|
tags: [redux, createSelector, shallowEqual, memoization, react-redux]
|
||||||
|
|
||||||
|
# Dependency graph
|
||||||
|
requires:
|
||||||
|
- phase: 30-component-memoization
|
||||||
|
provides: React.memo wrapper on container components
|
||||||
|
provides:
|
||||||
|
- Composed memoized selectors for mixer state (6 selectors)
|
||||||
|
- Optimized useMixerHelper hook with shallowEqual comparison
|
||||||
|
- Reduced selector subscriptions from 21 to 6
|
||||||
|
affects:
|
||||||
|
- phase-32 (final verification/testing)
|
||||||
|
|
||||||
|
# Tech tracking
|
||||||
|
tech-stack:
|
||||||
|
added: []
|
||||||
|
patterns:
|
||||||
|
- createSelector for grouping related Redux state
|
||||||
|
- shallowEqual for object return comparisons in useSelector
|
||||||
|
|
||||||
|
key-files:
|
||||||
|
created: []
|
||||||
|
modified:
|
||||||
|
- jam-ui/src/store/features/mixersSlice.js
|
||||||
|
- jam-ui/src/hooks/useMixerHelper.js
|
||||||
|
|
||||||
|
key-decisions:
|
||||||
|
- "Group selectors by usage pattern (core, track, lookup, metadata)"
|
||||||
|
- "Use shallowEqual comparison with composed selectors for object returns"
|
||||||
|
- "Preserve all variable names via destructuring for backward compatibility"
|
||||||
|
|
||||||
|
patterns-established:
|
||||||
|
- "Composed selectors: Use createSelector to group related state that changes together"
|
||||||
|
- "shallowEqual + createSelector: Prevents re-renders when grouped object contents unchanged"
|
||||||
|
|
||||||
|
# Metrics
|
||||||
|
duration: 3min
|
||||||
|
completed: 2026-03-05
|
||||||
|
---
|
||||||
|
|
||||||
|
# Phase 31 Plan 01: Selector Optimization Summary
|
||||||
|
|
||||||
|
**Composed memoized selectors using createSelector reduce useMixerHelper subscriptions from 21 to 6 with shallowEqual comparison**
|
||||||
|
|
||||||
|
## Performance
|
||||||
|
|
||||||
|
- **Duration:** 3 min
|
||||||
|
- **Started:** 2026-03-05T13:38:12Z
|
||||||
|
- **Completed:** 2026-03-05T13:41:00Z
|
||||||
|
- **Tasks:** 2
|
||||||
|
- **Files modified:** 2
|
||||||
|
|
||||||
|
## Accomplishments
|
||||||
|
- Created 6 composed memoized selectors in mixersSlice.js using createSelector
|
||||||
|
- Refactored useMixerHelper to use composed selectors with shallowEqual
|
||||||
|
- Reduced individual useSelector calls from 21 to 6 (total from 28 to 13)
|
||||||
|
- Preserved all existing variable names via destructuring for backward compatibility
|
||||||
|
|
||||||
|
## Task Commits
|
||||||
|
|
||||||
|
Each task was committed atomically:
|
||||||
|
|
||||||
|
1. **Task 1: Create composed selectors in mixersSlice.js** - `0630ebdd3` (feat)
|
||||||
|
2. **Task 2: Refactor useMixerHelper to use composed selectors** - `43b99c549` (feat)
|
||||||
|
|
||||||
|
## Files Modified
|
||||||
|
- `jam-ui/src/store/features/mixersSlice.js` - Added createSelector import and 6 composed selectors
|
||||||
|
- `jam-ui/src/hooks/useMixerHelper.js` - Replaced 21 individual selectors with 6 composed + shallowEqual
|
||||||
|
|
||||||
|
## Composed Selectors Added
|
||||||
|
|
||||||
|
| Selector | Groups | Purpose |
|
||||||
|
|----------|--------|---------|
|
||||||
|
| selectCoreMixerState | chatMixer, broadcastMixer, recordingMixer | Core mixer objects |
|
||||||
|
| selectTrackMixerState | 5 track mixer arrays | Track categorization |
|
||||||
|
| selectMixerLookupTables | allMixers, mixersByResourceId, mixersByTrackId | Lookup tables |
|
||||||
|
| selectMasterPersonalMixers | masterMixers, personalMixers | Source arrays |
|
||||||
|
| selectMixerMetadata | metronome, settings, mediaSummary, noAudioUsers, etc. | Metadata objects |
|
||||||
|
| selectSimulatedCategoryMixers | simulatedMusic, simulatedChat | Category controls |
|
||||||
|
|
||||||
|
## Decisions Made
|
||||||
|
- Grouped selectors by usage pattern rather than arbitrary groupings
|
||||||
|
- Used shallowEqual with all composed selectors since they return new objects
|
||||||
|
- Kept all existing variable names via destructuring to avoid breaking downstream code
|
||||||
|
|
||||||
|
## Deviations from Plan
|
||||||
|
|
||||||
|
None - plan executed exactly as written.
|
||||||
|
|
||||||
|
## Issues Encountered
|
||||||
|
- Build verification could not complete due to pre-existing node-sass/M1 Mac compatibility issue
|
||||||
|
- Syntax validation and eslint checks confirmed code correctness
|
||||||
|
|
||||||
|
## User Setup Required
|
||||||
|
|
||||||
|
None - no external service configuration required.
|
||||||
|
|
||||||
|
## Next Phase Readiness
|
||||||
|
- Selector optimization complete
|
||||||
|
- Ready for Phase 32 (final verification/performance testing)
|
||||||
|
- Integration testing recommended to verify no regressions
|
||||||
|
|
||||||
|
---
|
||||||
|
*Phase: 31-selector-optimization*
|
||||||
|
*Completed: 2026-03-05*
|
||||||
Loading…
Reference in New Issue