Skip to content

perf(sidebar): match ASCII names by bytes and filter each container once per query - #4596

Merged
datlechin merged 8 commits into
mainfrom
perf/sidebar-filter-off-main
Nov 26, 2026
Merged

datlechin merged 8 commits into
mainfrom
perf/sidebar-filter-off-main

Conversation

@datlechin

@datlechin datlechin commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

  • The scan. SidebarNameQuery folds the query once. An ASCII name against an ASCII query takes a byte search; any other name, any other query, and any locale that folds the 26 ASCII letters differently from bytes (Turkish folds I to a dotless ı) keeps localizedStandardRange, so every answer stays what it was.
  • One owner for the verdicts. SidebarViewModel keeps a DatabaseTreeBucketMemo per container, and SidebarTreeView.visibleSchemas and SidebarView's otherSchemaMatches and attachedSchemaMatches pass it as filter: to hierarchicalLoadedContent and loadedObjectBuckets. An unrelated publish during a search no longer filters every loaded container again, and SidebarTreeView computes schemas once per body.
  • Bindings are plumbing. The three bindings SidebarView.init hands over on every evaluation of its parent are plain properties, so the handover publishes nothing.

Measured with a swiftc -O probe of both searches, one pass over 100,000 ASCII names on this Mac:

Query localizedStandardRange byte search matches (both)
t 26.0 ms 1.0 ms 71,560
or 18.1 ms 1.4 ms 24,890
ord 20.4 ms 2.6 ms 24,890
order_item 25.9 ms 1.8 ms 445

A sweep of 300,000 random printable-ASCII name and query pairs gave the same tier from both paths under en; under tr_TR it gave 83 differences, which is why the locale check exists.

Left for a follow-up, on #4532: the scan in a @concurrent pass with cancellation and narrowing from the previous matches, and the outline nodes built once per catalog load (SQ6 of #4438). The filter's callers read its verdicts synchronously, from the outline's node build and from the bodies, so moving the scan off the main actor makes that an async pipeline; that is its own change.

Test plan

  • SidebarNameFilterTests: non-ASCII cases (ß, the fi ligature, İ and ı, combining and precomposed é, æ, Ø) answer what the locale-aware search answers in the current locale, so the case holds under Turkish too; every ASCII query against every ASCII name, punctuation included, matches the locale-aware search; a Turkish locale takes the locale-aware path.
  • SidebarViewModelTests: handing over new bindings publishes nothing; a container's remembered verdict follows its query; clearing the search lets go of the rows the container memo held (the memo is emptied on every query change, not only at the next lookup, which never comes once the field is empty).
  • verify.sh test SidebarNameFilterTests SidebarSearchTests SidebarViewModelTests DatabaseTreeFilterTests on the head merged with main: 70 passed.
  • SidebarNameMatchTier is declared Sendable: a public enum is not inferred so, and the test arguments need it (CI's compile error).

Closes #4532

…nce per query

The sidebar filter searched every name with localizedStandardRange. An ASCII name
against an ASCII query now takes a byte search, and the locale-aware search keeps
every other name and any locale that folds ASCII letters differently. The bodies
around the outline read one memo of container verdicts, and the view model's
bindings stop publishing when SidebarView hands them over.
@datlechin
datlechin enabled auto-merge (squash) November 26, 2026 01:51
@datlechin
datlechin merged commit 1f3363e into main Nov 26, 2026
0 of 2 checks passed
@datlechin
datlechin deleted the perf/sidebar-filter-off-main branch November 27, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(sidebar): filtering a 100,000-table catalog runs on the main thread on every key

1 participant