Skip to content

perf: save completed notebook runs in one document update - #26254

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-notebook-completed-run-batch
Oct 8, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-notebook-completed-run-batch

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Returning to a notebook after “Run All” finished in another tab can block the editor while Orca repeatedly rewrites the entire notebook. Save the completed cells together instead.

What Changed

Collect the finished runs in their existing order and reuse the same cell mutation to parse and serialize the notebook once. Preserve the successfully saved prefix when a later cell refuses an update, and still retire every captured run. The single-cell mutation keeps its throwing contract.

Why

For a generated 100-cell Python notebook (95,721 bytes, small stream and JSON outputs), the actual completed-run hook effect fell from 28.49 to 1.54 ms; whole-file parses fell from 101 to 2 and serializations from 100 to 1. At 50 cells it fell from 6.64 to 0.42 ms, and at 20 from 1.14 to 0.16 ms. One cell remained about 0.035 ms. These are seven alternating paired medians in production React with happy-dom, timing hook mount through persistence; kernel completion was seeded outside timing.

Batching follows the existing source-edit mutation pattern and removes repeated work without postponing saves, introducing a worker or changing notebook ownership. This measurement does not establish the cause of intermittent Codex typing pauses or measure the full viewer’s render time.

Linked Issue

Requested performance audit; no existing issue.

Visual Proof

Actual IpynbViewer in a freshly built, hidden Electron renderer: click Run All and its trust confirmation, switch away while the notebook stays open, deliver 100 controlled completions, then return. Both versions saved byte-identical formatted content and rendered identical text; all 100 runs committed and released their live outputs. Interpreter and kernel-frame IPC were controlled; no real Python or active Monaco worker was launched. This verifies the rendered flow, not total UI timing.

Before: Before

After: After

Testing

  • Manually validated the rendered flow locally through hidden Electron/CDP on macOS; owned app and private profile removed afterward.
  • Added regression coverage using the actual kernel session/store and hook. Original code fails the 20-cell serialization check; all seven cases pass after the change. Cases include a malformed middle cell retaining saved output and malformed/first-refused documents retiring runs without changing content.
  • Editor suite: 325 files, 2,452 tests pass; three existing tests skipped.
  • All seven hook cases also pass under Node Vitest. Renderer typecheck, changed-file quality checks and fresh Electron build pass.
  • Combined validation with the earlier audit fixes: 2,481 editor tests pass (three existing skips), full pnpm tc passes, and all 112 changed files have zero new quality findings.
  • 168 temporary paired hook controls preserve exact saved content and session state, including missing/running/already committed runs, duplicate IDs, malformed cells, Unicode, CRLF, transient fields, errors and 150 generated JSON notebooks.

Review

Independent source reviews confirmed the same cell lookup, key order, partial-save behavior and commit ownership for JSON-derived kernel frames. Python execution remains local; existing SSH refusal coverage passes. Folder workspaces still use the same notebook path and root. No wire, platform, shortcut, style, timing policy or persistent cache changes.

Agent skill upstream boundary

  • Not applicable.

Checklist

  • This PR is small and focused.
  • Explained the user-facing change, mechanism and choice of approach.
  • Before/after rendered screenshots attached.
  • Self-reviewed for correctness, security and performance.
  • Cross-platform, folder and SSH behavior considered.
  • Relevant tests, typecheck, changed-code quality and build pass. All selected hosted CI checks pass, including five Node 24 shards and macOS/Windows packaging.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df41930f-244e-4047-afe3-49f0db42c387
📥 Commits

Reviewing files that changed from the base of the PR and between 76d1b7b and 39d7cab.

📒 Files selected for processing (3)
  • src/renderer/src/components/editor/ipynb-cell-mutations.ts
  • src/renderer/src/components/editor/useIpynbCellExecution.test.tsx
  • src/renderer/src/components/editor/useIpynbCellExecution.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The execution hook now collects uncommitted cell results and applies them through one batch notebook mutation. The mutation applies updates in order and stops at the first failed cell update. Tests cover saved outputs and execution counts, retained metadata and tags, invalid documents, and run retirement.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 39d7c

Completed notebook runs are now saved in a single document update, which reduces parsing and serialization work. No merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description covers the user impact, implementation, rationale, visual proof, testing, review notes, and checklist. However, the required Linked Issue section does not provide an issue link and ins… Add a link to the actual issue addressed by this pull request under Linked Issue, using the required Fixes # format or another valid issue reference accepted by the repository.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: batching completed notebook runs into one document update for performance.
Full details: Description check

Explanation

The description covers the user impact, implementation, rationale, visual proof, testing, review notes, and checklist. However, the required Linked Issue section does not provide an issue link and instead states that no existing issue is available.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 8060ca5 into main Oct 8, 2026
30 checks passed
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