Repository navigation
Measure wide-dep useEffect cost; no fix warranted (bd-wfhd0dg5) - #936
Merged
shikokuchuo merged 2 commits intoOct 27, 2026
Merged
Conversation
Phase 4 of the useEffect audit (plan: claude-notes/plans/2026-10-24-hub-client-useeffect-refactor.md). Adds src/utils/perfCounters.ts — a QUARTO_PERF_STATS/localStorage/?perf=1 gated counter helper — and instruments the five fileContents-wide effects plus the intelligence refresh. Throwaway Node drivers (tsx + jsdom, real hooks, real Automerge doc, real WASM vfs_add_file) measured per-keystroke cost at geometric scales: - Reconcile effect: O(n) with small constant, <=0.27 ms at <=82 KiB docs; the redundant on-main vfs write is <=0.3 ms even at 327 KiB — not worth the branch-transition-tracking risk to skip. - useProjectSearch: corpus rebuild <=30 us at 400 files; the residual ~0.8 ms is intrinsic MiniSearch reindexing of the one changed file. - Trivial-body effects (route-nav, replay-VFS, preview schedulers, intelligence refresh): 0.036 ms/keystroke for five incl. React commit. No dep is narrowed and no work is moved; the counters stay in the tree. useSectionThumbnails was dead code (no caller; OutlinePanel imported only its ThumbnailMap type) — deleted, closing the debounce item. The refreshIntelligence effect is already debounced at 300 ms inside useIntelligence; no fold-in needed.
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #931. Phase 4 of
claude-notes/plans/2026-10-24-hub-client-useeffect-refactor.md(bd-wfhd0dg5).Measures before fixing, per the profiling playbook — and the data says no wide-dep fix is warranted:
src/utils/perfCounters.ts(gated onQUARTO_PERF_STATS=1/localStorage.quartoPerfStats=1/?perf=1, read once at startup; inert otherwise) and instruments the fivefileContents-wide effects plus the intelligence refresh. Gauges stay in the tree, same pattern as the Rustperf.interncounters.useAutomergeSync): O(n) with a small constant — 0.073 ms/keystroke at 20 KiB docs, 1.0 ms at 327 KiB (measured with the real hook against a real Automerge doc and the real WASMvfs_add_file; Monaco emulated as an upper bound). The on-main VFS write is redundant with the sync client but ≤ 0.3 ms even at 327 KiB — not worth the branch-transition-tracking risk to skip.useProjectSearch: the wide-dep corpus rebuild is ≤ 30 µs at 400 files; the residual ~0.8 ms/keystroke is MiniSearch reindexing the one changed file — intrinsic to a live index, independent of dep shape.useSectionThumbnailswas dead code (no caller;OutlinePanelimported only itsThumbnailMaptype) — deleted, closing the debounce item.refreshIntelligencealready debounces at 300 ms insideuseIntelligence; no fold-in needed.No user-visible behavior change, so no changelog entry (same call as Phases 2–3).
Tests: full
npm run test:cigreen (1736 unit, 229 integration, 434 WASM) andnpm run buildgreen; eslint on touched files at exact parity with the Phase 3 tip. Not verified in a real browser session — the only behavior change is the dead-code deletion; the counters are inert unless enabled.