Skip to content

perf(sidebar): debounce table search to keep typing responsive#1725

Open
desperadoxhy wants to merge 1 commit into
TableProApp:mainfrom
desperadoxhy:perf/sidebar-search-debounce
Open

perf(sidebar): debounce table search to keep typing responsive#1725
desperadoxhy wants to merge 1 commit into
TableProApp:mainfrom
desperadoxhy:perf/sidebar-search-debounce

Conversation

@desperadoxhy

Copy link
Copy Markdown
Contributor

问题

侧边栏表搜索框每敲一个字符就对全部表、视图、外键表跑全量模糊匹配。表上千张时打字明显卡顿。

方案

引入 debounce 后的 filterQuery 作为过滤输入(150ms),searchText 只负责即时显示。过滤缓存的指纹含 query,所以必须 debounce 查询本身,不能只 debounce 缓存失效。清空搜索与首次输入立即响应,连打时保留旧结果不闪烁。

验证

  • BUILD SUCCEEDED (Xcode 27 beta, CODE_SIGNING_ALLOWED=NO)
  • SidebarViewModelSearchDebounceTests 覆盖:首次输入立即更新、清空立即、debounce 窗口内保持旧值、debounce 后追上、缓存用 filterQuery 而非 searchText

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, you need to sign our Contributor License Agreement.

To sign, please comment below with:

I have read the CLA Document and I hereby sign the CLA.


I have read the CLA Document and I hereby sign the CLA.


xuhengyu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bfbf818ad5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


private var searchText: String {
viewModel.searchText
viewModel.filterQuery

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep hierarchical search-load debounce on live input

In the hierarchical schema sidebar, this searchText also drives the .onChange(... scheduleSearchLoad) path below. Because it now only changes when filterQuery changes, the load task queued for the first character is not canceled by subsequent live keystrokes while filterQuery is held; on a long continuous query it can fire after 300 ms and load every schema for the stale 1-character query, reintroducing the expensive work this debounce is meant to avoid. Keep the schema-load cancellation keyed off viewModel.searchText or cancel it from the live input.

Useful? React with 👍 / 👎.

@desperadoxhy

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

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.

1 participant