Skip to content

perf(files): reduce tombstone query overhead - #617

Closed
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-file-index-tombstones-wave5
Closed

perf(files): reduce tombstone query overhead#617
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-file-index-tombstones-wave5

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Compacts deleted-heavy primary prefix buckets after watcher tombstone batches, gated by tombstone count and bucket density so broad low-value buckets stay untouched.
  • Tracks exact deleted normalized names on the active snapshot and skips macOS Spotlight fallback for exact deleted-name queries with no live indexed result.
  • Extends delete-batch tests and benchmark output to cover post-delete query cost and touched bucket size.

Why

Post-delete queries could spend tens of milliseconds after watcher delete batches because tombstoned IDs remained in prefix buckets and exact deleted-name misses fell through to Spotlight. The new path keeps dense tombstone buckets lean and avoids asking Spotlight to rediscover a name the index just tombstoned.

Compatibility impact

Raycast-facing result shapes and delete semantics are preserved: exact file deletes, directory descendant deletes, unknown-root descendant tombstones, prefix-like sibling safety, and nested delete collapse still pass. The Spotlight skip is limited to exact deleted-name tombstones when the live index has no result.

How tested

  • node scripts/test-file-search-delete-batch.mjs
  • node scripts/test-file-search-index.mjs
  • node scripts/test-file-search-perf-harness.mjs
  • ./node_modules/.bin/tsc -p tsconfig.main.json --noEmit --pretty false
  • npm run build:main via real cached npm CLI
  • npm run build:renderer via real cached npm CLI
  • node scripts/build-native.mjs
  • npm test via real cached npm CLI
  • LSP diagnostics for src/main/file-search-index.ts and workspace diagnostics; LSP references checked for tombstoneDeletedPaths
  • git diff --check

Note: top-level npm run build was also attempted, but this machine's nested npm resolution fails before project build steps with Cannot find module ... npm-prefix.js; running the component build steps directly passed.

Performance evidence

Parent-sized harness (node scripts/file-search-perf-harness.mjs --projects 40 --modules 6 --files-per-module 10 --query-runs 8 --updates 64 --deletes 64 --limit 20 --json):

  • Before: post-delete query 39.066 ms; delete batch 3.569 ms; normal query p95 3.895 ms; path-like p95 4.270 ms.
  • After: post-delete query 2.583 ms; delete batch 3.597 ms; normal query p95 3.511 ms; path-like p95 3.875 ms.

Larger delete-heavy harness (--projects 80 --modules 8 --files-per-module 16 --query-runs 6 --updates 96 --deletes 256 --limit 20 --json):

  • Before: post-delete query 33.386 ms; delete batch 5.257 ms; event-loop lag p95 2.109 ms.
  • After: post-delete query 2.645 ms; delete batch 5.575 ms; event-loop lag p95 1.915 ms.

Focused delete benchmark after change (node scripts/benchmark-file-search-delete-batch.mjs):

  • direct-file-batch: 80,161 entries, 500 delete paths, 500 deleted, delete 5.997 ms, post-delete query 8.599 ms, touched bucket 80,161 -> 80,161.
  • directory-tree-batch: 68,162 entries, 4,041 delete paths, 8,041 deleted, delete 13.509 ms, post-delete query 15.947 ms, touched bucket 8,041 -> 0.

Stack validation

Base was exact ac90ce403aeddab98d0a1b245afce268c48b8bfd from codex/perf-wave4-integrated-stack-20260705. Branch codex/perf-file-index-tombstones-wave5 contains one commit: 90df743 perf(files): reduce tombstone query overhead.

Replaces

N/A

(cherry picked from commit 83c2a89)
(cherry picked from commit 0a7560b)
# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…launcher surfaces

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…IO stalls

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
…resh overhead

# Conflicts:
#	scripts/bench-script-command-discovery.mjs
#	scripts/benchmark-file-search-delete-batch.mjs
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-file-search-delete-batch.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/file-search-index.ts
#	src/main/main.ts
…hurn

# Conflicts:
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-extension-lifecycle-sandbox.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
… hot paths

# Conflicts:
#	scripts/test-use-frecency-sorting.mjs
#	src/renderer/src/raycast-api/form-runtime.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/grid-runtime-items.tsx
#	src/renderer/src/raycast-api/hooks/use-frecency-sorting.ts
# Conflicts:
#	.github/workflows/project-checks.yml
#	package.json
#	scripts/file-search-perf-harness.mjs
#	scripts/test-browser-search-performance.mjs
#	scripts/test-file-search-perf-harness.mjs
#	scripts/test-root-search-perf.mjs
#	src/renderer/src/CameraExtension.tsx
#	src/renderer/src/hooks/useBrowserSearch.ts
#	src/renderer/src/raycast-api/list-runtime.tsx
…cle and media fixes

# Conflicts:
#	scripts/lib/ts-import.mjs
#	scripts/measure-extension-bundle-cache.mjs
#	src/main/commands.ts
#	src/main/extension-runner.ts
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/list-runtime-hooks.ts
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated PR #620: #620

@JustYannicc JustYannicc closed this Jul 5, 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.

1 participant