Skip to content

perf: Index requested cells for queued runs - #12244

Merged
kirangadhave merged 1 commit into
mainfrom
kg/index-requested-cells
Dec 2, 2026
Merged

kirangadhave merged 1 commit into
mainfrom
kg/index-requested-cells

Conversation

@kirangadhave

Copy link
Copy Markdown
Member

This pull request was authored by a coding agent.

📝 Summary

Index the requested cell IDs when a queue check first needs them. Reuse the index across cell reads that share the same list. A weak cache ties the index to the lifetime of that list. Queue checks still account for planned executions, disabled and blocked cells, and overlapping runs.

Addresses the requested-cell membership part of MO-8797.

Requested cells Before After Speedup
500 0.0964 ms 0.0277 ms 3.48×
2,000 1.1942 ms 0.1078 ms 11.08×

Each sample reads every cell view for one accepted run before the kernel plans any executions. The table shows the median of three p50 measurements per revision on an Apple M4 Pro with Node 26.13.0. The benchmark measures repeated selector reads after warmup. Index construction, browser rendering, and kernel time are outside the timed region.

pnpm --dir frontend exec vitest bench benchmarks/queued-run.bench.ts --mode test --run --no-file-parallelism
  • 111 execution tests passed. The new tests check index reuse across snapshots and separate lists for matching run IDs.
  • The frontend typecheck passed. Oxlint and Oxfmt passed for all three changed files.

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes.

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Reading each cell in an accepted run repeatedly scanned the same requested-cell list until the kernel supplied a plan. Cache membership by list identity so updates that reuse the list share the index.
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 29e8a9e.

@kirangadhave kirangadhave changed the title Index requested cells for queued runs perf: Index requested cells for queued runs Dec 2, 2026
@kirangadhave
kirangadhave requested a balanced review from Copilot December 2, 2026 19:01
@kirangadhave
kirangadhave marked this pull request as ready for review December 2, 2026 19:01

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.

🟡 Changes recommended

The benchmark covers only warmed-cache reads, leaving cold accepted runs and overlapping runs with planned, disabled, or blocked cells without recorded human validation.

1 open issue
What changed in this PR

Speeds up queued-cell checks by caching requested-cell membership indexes across reads and run snapshots that share the same list.

Changes:

  • Adds a lazy, weakly cached membership index.
  • Tests index reuse and isolation between distinct lists.
  • Adds warmed-cache benchmarks for 500 and 2,000 cells.
File Description
frontend/​src/​core/​executions/​select.ts Replaces repeated list scans with cached set lookups.
frontend/​src/​core/​executions/​__tests__/​select.test.ts Tests cache reuse and separate-list behavior.
frontend/​benchmarks/​queued-run.bench.ts Measures repeated queued-cell selector reads.

Review effort: Balanced

Comment on lines +35 to +39
await bench("read every cell view", () => {
for (const id of ids) {
cellExecutionView(inputs, id);
}
}).run({ time: 500, warmupTime: 200, iterations: 100 });
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./frontend

Status Category Percentage Covered / Total
🔵 Lines 69.02% 28573 / 41397
🔵 Statements 68.96% 29122 / 42227
🔵 Functions 64.16% 6834 / 10651
🔵 Branches 64.43% 16724 / 25955
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
frontend/src/core/executions/select.ts 96% 92.7% 95.83% 95.95% 118, 140, 325, 330
Generated in workflow #26487 for commit 29e8a9e by the Vitest Coverage Report Action

@kirangadhave
kirangadhave merged commit 61700e3 into main Dec 2, 2026
37 of 39 checks passed
@kirangadhave
kirangadhave deleted the kg/index-requested-cells branch December 2, 2026 19:33
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.26.1-dev104

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