fix(simulate): wrap only new log lines each frame - #932
Open
u9g wants to merge 1 commit into
Open
Conversation
renderLogs re-wrapped the entire agent log history on every frame to show height/3 lines. At 120k lines that is ~900ms per View() against an 80ms spinner tick, so the TUI dropped to about one frame per second with the log pane open on a 100-job run. Cache the wrapped whole-run log lines, keyed by wrap width, and wrap only the newly appended tail. Measured 912ms -> 1ms at 120k lines; output is byte-identical across appends, scroll offsets, resizes and offset clamping.
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
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.
renderLogsre-wrapped the whole agent log history every frame to displayheight/3lines, so cost scaled with total log volume (~7.6µs/line). With the log pane open (Ctrl+L) on a 100-job run that is ~900ms perView()against an 80ms spinner tick — the TUI drops to roughly one frame per second.Measured
View()at 160x45, 100 jobs:At 120k lines the
RecentLogs(0)copy is 158µs and the lipgloss re-wrap is 917ms, so the wrap is the entire cost.The whole-run buffer is append-only, so this caches the wrapped lines on the model and wraps only the new tail; a width change or a buffer shrink rebuilds. The per-room path (job detail view) is bounded by one conversation and is unchanged.
Verified byte-identical to the previous wrap-everything output across appends, scroll offsets, resizes and offset clamping.