-
Notifications
You must be signed in to change notification settings - Fork 0
Optimize arch #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Move text and block rendering before the outline so borders and outlines are drawn last and always overlay content. Remove duplicate rendering block at the end of the function. Preserve stack='z' behavior and compute child clip from padding.
Detect vertical content shifts and emit a DECSTBM scroll prefix to perform fast terminal scrolls. Map previous row indices to avoid redrawing scrolled lines and track scrollOps in DiffStats. Also update render paths, improve ANSI sanitize regex, and add unit tests.
Introduce a view/dirty module and proxy-based tracking for style and children mutations. Renderer now samples dirty versions and the hasScrollRegion hint to skip layout/collect traversals and short- circuit renders when nothing changed. Add renderer.invalidate and call it from LoopManager cleanup. Make TextElement.content setter mark render-only dirty to avoid unnecessary layout.
Reconcile next immediate-mode ViewElement trees into the retained previous tree to preserve object identities and avoid spurious dirty marks. Add reconcileTree and setDirtyVersions, export a retained cache, optimize BaseView key/identifier setters, adjust windowed/virtual-list layout, and add a test to ensure unchanged frames are skipped.
Reduce excessive cursor moves by batching printable text into a pending buffer and flushing only when control sequences are emitted. Introduce pushCtl/flushText/moveTo helpers and an "inRun" fast-path to coalesce adjacent glyph writes. Add renderFullRedraw and renderFullRedrawAscii for size changes (update stats and preserve scrollPrefix behavior). Update tests to reflect batched output and new cursor move counts
Introduce ViewportSlice primitive for rendering visible list slices. Add getWindowedMetrics and clampWindowedStartIndex; Windowed now uses terminal-height fallback and delegates to ViewportSlice. Update examples, tests, and profiler script to use the new APIs.
Use a scheduler with queueMicrotask and a `scheduled` flag so the render effect is run at most once per microtask cycle. Add a unit test that verifies multiple reactive updates are coalesced into a single additional render.
Add RenderDiff.scrollOp to apply an explicit DECSTBM scroll (with normalization/validation) so callers can skip scroll detection. In the render loop restrict DECSTBM to a single scroll region, return the scroll op from the fast scroll path, and introduce a dirty-rect path that reuses previous buffers when only render props change. Update map collection logic and add unit tests for both behaviors.
Mark layout dirty when Text content changes if width or height are auto/undefined. Add a test that verifies the renderer re-runs layout when intrinsic text content changes and adjust an existing test to use explicit sizing.
Add an uncaughtException listener that restores terminal state (show cursor, disable bracketed paste, and perform cleanup without clearing) to avoid leaving the TTY in raw mode after fatal errors. The listener removes itself on cleanup and rethrows the error asynchronously if it's the only listener to preserve default runtime behavior. Include a unit test and update the roadmap checkbox.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and new features, primarily focused on performance profiling, scalability testing, and incremental FFI communication for the layout engine. It adds new profiling scripts for virtual scrolling, refactors the scalability profiler for more accurate and synchronous measurements, and implements incremental FFI operations with dirty checking in the layout engine. Additionally, the roadmap is updated to reflect completed optimizations.
Profiling and Scalability Improvements:
examples/virtual-list.ts) demonstrating efficient rendering of a 50,000-item virtualized list with keyboard navigation and windowed scrolling.scripts/profiler-scroll.spec.ts) to measure and assert the performance of windowed scrolling with large lists, ensuring frame times remain below 16.7ms for 60 FPS.scripts/profiler-limit.spec.ts) to use synchronous frame driving, improved node count scaling, and removed reliance on file output for internal measurements, increasing accuracy and repeatability. [1] [2] [3]Layout Engine Enhancements:
Documentation Updates:
docs/roadmap.ja.md) to mark FFI communication optimization, virtual scrolling, fast scroll region support, and fatal error safety net as completed.Most important changes:
Profiling and Examples
examples/virtual-list.tsto demonstrate performant virtual scrolling of 50,000 items with keyboard navigation.scripts/profiler-scroll.spec.tsfor automated profiling and validation of windowed scrolling performance with large lists.scripts/profiler-limit.spec.tsfor more precise and synchronous scalability testing, improving measurement accuracy and test reliability. [1] [2] [3]Layout Engine
src/layout-engine/index.ts, including new helpers for style/children serialization and new FFI bindings for efficient updates. [1] [2] [3] [4] [5] [6]Documentation
docs/roadmap.ja.mdto reflect completion of key architecture and optimization milestones, including FFI efficiency and large-scale rendering support.