Repository navigation
perf(scene-bar): memoize tabItems compilation to prevent redundant tab allocations - #3799
Raing5Days wants to merge 1 commit into
Conversation
|
Thanks for proposing this optimization! During review, we found that Since this PR also has merge conflicts, I reimplemented the optimization against the latest code in #3911. It stabilizes the upstream references, narrows store subscriptions, and adds regression tests. Across three jsdom React Profiler runs with 24 tabs and 100 updates per scenario, average render time decreased by approximately 34% for parent re-renders and 49% for simulated tab-selection updates. These measurements do not represent native UI frame rates. All 101 focused tests and TypeScript checks passed. Closing this PR in favor of #3911. Thanks again for the contribution! |
## Summary
Optimize
SceneBartab list compilation by wrappingtabItemscreation inuseMemo, eliminating unconditional re-allocation of 20+TabGroupItemobjects, JSX button end-actions, and badge nodes on unrelated re-renders.shownTabs.reduceinto a dedicateduseMemoanchored onshownTabs,sessionLabels,resources,tabDefs, and i18n translators.@openbitfun/ui'sTabGroup, allowing downstream tab items to skip virtual DOM re-diffing and keep focused hit targets intact.Type and Areas
Performance / refactoring. Web UI layout and scene tabs (
src/web-ui/src/app/components/SceneBar/SceneBar.tsx). No wire protocol, persisted schema, or styling regressions.Motivation / Impact
Previously,
SceneBarexecutedshownTabs.reduceunconditionally at the component root level. In sessions with many tabs (e.g. 15–25 tabs, opening overflow strips):TabGroupItemobjects, button JSX nodes, and close handlers.TabGroupreceived a completely new items array reference on every frame, forcing redundant reconciliations across all tab DOM elements.With
useMemo:TabGroupItemarrays and child button structures remain referentially identical across active scene switches and scrolling unless tab definitions or titles actually change.OpCase-Tab-Dehydration-01, 24 tabs, 20 switches) demonstrates:Verification
node scripts/run-vitest.mjs run --maxWorkers=50% "src/app/components/SceneBar/SceneBar.test.tsx"— 24 passed (100%).node scripts/check-repo-hygiene.mjs— passed.node --test scripts/check-repo-hygiene.test.mjs— 3 passed (100%).node scripts/verify-release-version-sync.mjs— passed.node scripts/format-changed-rust.mjs— passed.git diff --check— clean.Checklist