Skip to content

fix: speed up incremental search indexing - #12818

Merged
tiensonqin merged 4 commits into
masterfrom
logseq/fix-search-index-sync-perf
Jun 24, 2026
Merged

tiensonqin merged 4 commits into
masterfrom
logseq/fix-search-index-sync-perf

Conversation

@tiensonqin

Copy link
Copy Markdown
Contributor

Summary

Speed up incremental search indexing after outliner transactions by avoiding vector-context expansion on direct block changes.

Root cause

sync-search-indice was expanding each affected block to nearby vector context and then building contextual vector titles for every indexed block. Bulk insertion of sibling blocks repeatedly touched the same sibling sets, which made the indexing path scale poorly.

Changes

  • Default include-vector-title? to false for sync-search-indice.
  • Only include vector titles from the db listener when a vector index exists.
  • Build incremental vector titles from the block's own title instead of nearby parent/sibling/child context.
  • Simplify affected-block collection so parent/page/order changes index direct entities only.
  • Preserve subtree removal for :logseq.property/deleted-at, where page/block descendants must leave the index.
  • Add 300-block performance regressions for semantic-search enabled and disabled paths with a 1s guard.

Benchmark

Direct sync-search-indice timing for 300 newly inserted sibling blocks after the change:

  • semantic search enabled: 222.306ms, blocks-to-add=300
  • semantic search disabled: 213.032ms, blocks-to-add=300

Verification

  • clojure -M:test compile test
  • env LOGSEQ_STABLE_IDENTS=1 node static/tests.js -v frontend.worker.search-test
  • env LOGSEQ_STABLE_IDENTS=1 node static/tests.js -v frontend.worker.db-listener-test
  • git diff --check

Copilot AI review requested due to automatic review settings June 24, 2026 11:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR speeds up incremental search indexing after outliner transactions by avoiding vector-context expansion and by indexing only the directly affected entities (except for subtree removals on deletion), reducing repeated work during bulk sibling inserts.

Changes:

  • Update sync-search-indice to (by default) skip vector-title generation and to index only directly affected blocks for structure changes, while preserving subtree removal for :logseq.property/deleted-at.
  • Include vector titles from the DB listener only when a semantic/vector index is present.
  • Add/adjust tests to validate the new “directly affected only” behavior and add a 300-block performance regression guard for semantic-search enabled/disabled paths.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/test/frontend/worker/search_test.cljs Updates incremental-indexing expectations and adds deletion + performance regression tests.
src/main/frontend/worker/search.cljs Refactors affected-entity collection and adds an incremental indexing path that can omit vector titles by default.
src/main/frontend/worker/db_listener.cljs Gates incremental vector-title inclusion on the presence of a vector index.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RCmerci

RCmerci commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@codex review pr

@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: 30d4fae08c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/frontend/worker/search.cljs Outdated
set)]
{:blocks-to-remove (distinct
(concat (entities-with-referrers-for db-before ref-eids)
(entities-for db-before direct-visibility-eids)

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 Remove hidden subtrees on parent visibility changes

When a page or block subtree becomes hidden only because its :block/parent changes, such as moving it under a parent that already has :logseq.property/hide?, the transaction only needs to contain the root parent datom. hidden-entity? follows hidden parents, but this direct-only removal path now drops just the root from the search indexes, leaving already-indexed descendants searchable until a full rebuild; the previous include-tree? path removed the whole affected subtree for these visibility changes.

Useful? React with 👍 / 👎.

Comment thread src/main/frontend/worker/search.cljs Resolved
@tiensonqin
tiensonqin force-pushed the logseq/fix-search-index-sync-perf branch from 30d4fae to 69b60c6 Compare June 24, 2026 12:24
@tiensonqin
tiensonqin merged commit d53153c into master Jun 24, 2026
11 checks passed
@tiensonqin
tiensonqin deleted the logseq/fix-search-index-sync-perf branch June 24, 2026 13:35
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 1, 2026
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
devin-ai-integration Bot pushed a commit that referenced this pull request Oct 8, 2026
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.

3 participants