Repository navigation
perf(sidebar): pace the filter by its last refresh and rank Open Quickly without sorting every match - #4433
Merged
Conversation
datlechin
marked this pull request as ready for review
November 23, 2026 08:04
datlechin
enabled auto-merge (squash)
November 23, 2026 08:04
This was referenced Nov 23, 2026
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.
Summary
Perf audit 2026-11-22, finding 14 (sidebar and Open Quickly).
FuzzyMatcher.score(_:_:scratch:): an ASCII byte path with two reused rows and no traceback, same scores asmatch. Anything else (non-ASCII, CR, over 1,024 or 64 characters) takes theCharacterpath.TopRanked, a bounded heap. The ranking, the browse lists and the Connections scope keep their top rows instead of sorting every match. Ties keep catalog order, as the old sort did.QuickSwitcherViewModel+Ranking.swift.SidebarFilterPacerandRunLoopTurn: a refresh is timed from thefilterQuerywrite to the end of the run loop turn that rebuilt the outline. Each outline reports its rebuild throughnoteSearchRebuild(for:).Measured on an M4 MacBook Pro, interleaved. Before: a Release build of 9d0d481 (universal). After:
build.sh app arm64 --unsignedof this branch. Harness: the perf audit'sui-responsiveness(--scenarios catalog,tabs,--quick --no-lldb --no-profile) anddb-roundtrips(--engines pg --phases count). Medians, n=6 (catalog) or 4 (tabs); load1 3 to 17, so instruction and statement counts are the numbers to trust.lc_t250120 ms apart on 50,000 tables: process instructionstab_on 26 tables, keys 400 ms apart: later keys minus key 1t25on 50,000 tables, 400 ms apart: later keys to framepg_databaseandinformation_schema.schematareads. The table opened after Database > Refresh still reads both, since a refresh moves the schema generation, as before.Tests changed on purpose:
SidebarViewModelSearchDebounceTests: "filterQuery stays at previous value during debounce window", "filterQuery catches up after debounce window elapses" and "rapid consecutive keystrokes collapse to the final value" pinned a fixed 150 ms; they now run after a slow refresh. "filterQuery clears immediately when search becomes empty" and "filter caches still serve filteredTables using filterQuery, not searchText" report a slow refresh first, since they need a pending wait.QuickSwitcherCatalogStoreTests: "A bumped content revision misses" and "An unscoped content change invalidates every cached connection" split per part. The fixture now keeps one browse scope per case, so a miss test misses only on the field it changes.Deliberately not fixed here:
AppSettingsManager, already left in feat(settings): native macOS Settings sidebar with pushed pages and history #4413. The rest only pays off with SQ4 or SQ7.ui-responsivenessstep aborted. No gate could be decided. The first keyton 50,000 tables still stalls 110 to 170 ms here, at load 3 to 14.quick-open-result, 184.8 ms) is not re-recorded: it belongs to another machine.Test plan
FuzzyMatcherScoreTests(score equalsmatchover ASCII, mixed case, NFC and NFD, emoji, CRLF, 1,025 characters, a 65-character query, every separator),TopRankedTests(equals a stable sort's prefix, ties included),QuickSwitcherRankingTests(the new ranking equals a reference copy of the old one on 5,000 items),SidebarFilterPacerTests,RunLoopTurnTests, six pacing cases inSidebarViewModelSearchDebounceTests, four catalog store cases.FuzzyMatcherTests,QuickSwitcherViewModelTests,QuickSwitcherCrossSchemaTests,QuickSwitcherRecentIdentityTests,SidebarViewModelTests.verify.sh teston the 12 suites above: 189 passed. Codex adversarial review, then review: clean after the catalog store fixture fix.