Repository navigation
perf(notebook): draw only the end of long cell output, at bounded cost per frame - #28967
brennanb2025 wants to merge 4 commits into
Conversation
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
30a5a096-c7c4-4e50-aa32-5b14fb8680c7
📒 Files selected for processing: 17
src/renderer/src/components/editor/IpynbCellOutputs.tsxsrc/renderer/src/components/editor/IpynbRendering.test.tsxsrc/renderer/src/components/editor/ipynb-kernel-outputs.test.tssrc/renderer/src/components/editor/ipynb-kernel-outputs.tssrc/renderer/src/components/editor/ipynb-output-tail.test.tssrc/renderer/src/components/editor/ipynb-output-tail.tssrc/renderer/src/components/editor/ipynb-parse.test.tssrc/renderer/src/components/editor/ipynb-parse.tssrc/renderer/src/components/editor/ipynb-stream-text.tssrc/renderer/src/components/editor/useIpynbCellExecution.test.tsxsrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| return <IpynbMarkdownCell source={valueToText(item.value)} /> | ||
| } | ||
| return <TextOutput text={valueToText(item.value)} /> | ||
| return <TextOutput drawn={drawnText(valueToText(item.value))} /> |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift
Bound plain-text display data before converting it.
If a text/plain display item holds a large line array, valueToText(item.value) joins the entire array before drawnText keeps its tail. Opening that output still allocates and processes the full text. Apply the bounded multiline conversion before rendering the plain-text item.
| return ( | ||
| <div className="flex min-w-0 flex-col gap-1 pt-2"> | ||
| {cell.outputs.map((output, index) => ( | ||
| {cell.outputs.slice(0, DRAWN_OUTPUTS_PER_CELL).map((output, index) => ( |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift
Apply the output limit before parsing all outputs.
This slice bounds React output elements, but parseCell in src/renderer/src/components/editor/ipynb-parse.ts first maps parseIpynbOutput over every raw output. A cell with many outputs therefore still parses and allocates an unbounded number of records on its first draw. Carry the raw output count for the notice, and parse only the outputs that can be shown.
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/renderer/src/components/editor/IpynbRendering.test.tsx: 1
138-139: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRequire both spies to record calls.
The bound assertion passes for an empty call list because
Math.max(...[])returns-Infinity. Assert that both ANSI operations ran before checking their maximum input sizes.Suggested fix
+ expect(parseSizes).not.toHaveLength(0) + expect(rangeSizes).not.toHaveLength(0) for (const sizes of [parseSizes, rangeSizes]) { expect(Math.max(...sizes)).toBeLessThanOrEqual(chain ? 17 : 8192)
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f86daf46-bd0b-41bc-8ee3-f96ac36bd313
📒 Files selected for processing: 1
src/renderer/src/components/editor/IpynbRendering.test.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
Large notebook output could freeze the window because each update redrew completed text. The original output limit also hid errors and kernel-exit details once a cell produced more than 500 output records. The bounded view now reuses completed text while updating the changing progress line, preserves the previous color and carriage-return behavior, and keeps the latest error and final output visible within the 500-record limit. Complete output remains available to saving and Source view. The review also removed the historical scan of an arbitrarily long unfinished line and bounded saved text-array preparation before joining it. Verification on current head Remaining limits: full display-format conversion, visiting every saved output record, complete notebook serialization, and aggregate memory are outside the drawing guarantee. The earlier 55–114 ms first-output layout task remains an open measurement limitation; the repaired-head rerun has not established a new value. Opening hidden output in a read-only editor is tracked in STA-10710; reopening saved notebooks over 50 MB is tracked in STA-10711. Remote validation is blocked, so this PR is not ready to merge. The available test machines repeatedly fell below the required memory headroom. On the original measurement machine, every approved UI driver also failed its startup check through authentication, unavailable-model or quota errors. No test Orca window was launched; there are no screenshots to review yet. These are missing results, not passing checks. The two remaining review threads concern the disclosed full display-data conversion and visit to every saved output record; neither is being claimed fixed. For Brennan’s reviewStill needed: whole-window main/branch screenshots of normal execution and saved tail diagnostics, the branch progress-identity check, and the same-machine performance rerun. The following source decisions have completed review:
|
ELI5
A notebook cell that printed a large amount of text could freeze the Orca window because each update made the window process and draw accumulated output. The cell now shows a bounded end of each long text output while keeping the complete output for saving. Changing a progress line reuses the completed text already drawn.
What Changed
Text output shows its last 5,000 lines and at most 1,048,576 UTF-16 units. “Earlier output is hidden.” appears above truncated text. A cell draws at most 500 output records; the latest error and final record remain visible, with the selected records in their original order. The existing hidden-output count stays below the outputs.
Completed text is retained as small immutable pieces, with the changing current line interpreted separately. Pieces carry color state through the existing parser and become reusable once their control sequences are settled. Carriage-return updates process incoming text and retained line metadata instead of scanning an arbitrarily long earlier line. Saved text arrays select a bounded suffix before joining and normalizing it. The full notebook data remains separate from these drawing caches.
Why
Keeping output was not the source of the repeated drawing work. Separating saved data from visible text preserves the user's results while avoiding repeated processing of completed text. Dropping old output would lose data; rescanning the full output before taking its end would retain the original growing cost.
The common pattern retains completed presentation and updates the changing suffix. Intended differences are the exact combined line/character cap, existing carriage-return and color-code behavior, and retaining final diagnostics inside the output-record limit. A color sequence cut by the outer display boundary still starts with fresh color state and can leave stray characters, as on the original bounded implementation.
Temporary gaps: opening hidden output in a read-only editor is tracked in STA-10710; reopening notebooks larger than the existing 50 MB file-opening limit is tracked in STA-10711. This change also does not bound conversion of every display format or eliminate the initial visit to all output records.
Linked Issue
STA-8495 (duplicate STA-8641). Replaces #28087.
Visual Proof
Remote before/after Electron screenshots are pending. This PR remains in validation.
Testing
Current reviewed head:
9d980079727e8a6e415b849b26c1080104f0fe5a.On a separate macOS machine, the ten named notebook and shared ANSI test files passed: 150 passed, four existing skips. These cover complete saved output and reducer parity, caps, latest-error/final-record selection, completed DOM retention, and bounded parser/range-discovery inputs. The branch Electron production build also passed. The normal pre-commit hook passed before pushing.
The full PR workflow is pending on the current head. Actual main/branch Electron interaction, screenshots and the same-machine performance rerun remain pending; passing unit tests and the build do not establish those results.
Earlier measurements on this machine found a 55–114 ms first-output layout task. That is a known measurement limitation awaiting the repaired-head rerun, not a timing claim about the current commit. Full JSON parsing/saving, display-format conversion, visiting all output records and aggregate notebook memory remain outside the drawing guarantee.
Review
Three semantic review rounds and the final independent three-model design panel are complete; all three accepted the design. Final runtime validation, review-thread disposition and the loop status comment remain pending.
Agent skill upstream boundary
Notes
Saved output and Source view retain complete notebook data. Folder workspaces use the same drawing path. This adds no persisted format or remote protocol field. Notebook execution keeps its existing local-file restriction; remote notebooks receive the saved-output drawing behavior.