Skip to content

perf(grid): binary-search visible virtual rows#544

Closed
JustYannicc wants to merge 38 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-grid-visible-row-range
Closed

perf(grid): binary-search visible virtual rows#544
JustYannicc wants to merge 38 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-grid-visible-row-range

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Replaced Grid visible-row filtering with binary bounds over row bottoms/tops, then slices the matching row range.
  • Added focused tests for inclusive viewport/overscan boundaries and an instrumented 100k-row lookup shape check.

Why

getVisibleVirtualRows previously scanned every virtual row on each viewport update. The new lookup keeps scroll updates tied to logarithmic bound checks plus the visible slice, which avoids total-row scaling for large grids.

Compatibility impact

  • Preserves the existing overlap predicate: row.top + row.height >= start && row.top <= end.
  • Keeps partially visible rows and overscan edge inclusions intact.
  • No public API changes.

How tested

  • Before metrics, linear scan over 1,000 viewport queries:
    • 5,000 items / 1,001 rows: 6.282 ms
    • 50,000 items / 10,001 rows: 60.661 ms
    • 100,000 items / 20,001 rows: 100.916 ms
  • After metrics, binary range lookup over the same 1,000 viewport queries:
    • 5,000 items / 1,001 rows: 1.060 ms
    • 50,000 items / 10,001 rows: 0.458 ms
    • 100,000 items / 20,001 rows: 0.781 ms
  • node scripts/test-grid-virtualization.mjs
  • pnpm exec tsc -p tsconfig.renderer.json --noEmit
  • pnpm test (163 passed, 1 skipped)
  • TypeScript LSP diagnostics on src/renderer/src/raycast-api/grid-runtime-virtualization.ts: no errors; references are declaration plus the grid-runtime.tsx import/use.

Stack validation

Draft until the consolidated performance stack lands. Depends on consolidated PRs #530-#535 and integration branch JustYannicc:codex/perf-consolidated-integration-stack.

This branch is intentionally stacked on that integration branch: the virtualization helper and focused test script are introduced by the dependency stack, so a clean origin/main cherry-pick cannot represent only this fix yet.

…s' into codex/perf-consolidated-integration-stack
…nd-menubar' into codex/perf-consolidated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…emoji' into codex/perf-consolidated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
… into codex/perf-consolidated-integration-stack
…tus' into codex/perf-consolidated-integration-stack
… into codex/perf-consolidated-integration-stack

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated upstream PR #555.

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