Skip to content

perf: bound terminal output scheduling - #641

Open
dliu120 wants to merge 2 commits into
migueldeicaza:mainfrom
dliu120:perf/coalesce-terminal-output
Open

perf: bound terminal output scheduling#641
dliu120 wants to merge 2 commits into
migueldeicaza:mainfrom
dliu120:perf/coalesce-terminal-output

Conversation

@dliu120

@dliu120 dliu120 commented Aug 18, 2026

Copy link
Copy Markdown

Why

Large PTY reads can monopolize the main delivery queue, while interactive output and hidden terminal views can continue presentation work in the same main-loop turn. Both reduce the time available for input handling during heavy terminal output.

What changed

  • Deliver queued PTY output in ordered slices of at most 16 KiB while preserving the existing read size and backpressure thresholds.
  • Coalesce interactive display requests through the existing pending-display gate, including feeds already running on the main thread.
  • Add an explicit presentation-active state: parsing continues while hidden, but display, accessibility, Metal, cursor/text blink, and related callbacks pause.
  • Generation-gate queued presentation callbacks so stale work cannot resume after visibility transitions.
  • Mark the full screen dirty and schedule one refresh when presentation resumes.
  • Preserve synchronized-output behavior.
  • Remove a duplicate debug-display update from the display wrapper.
  • Add focused coverage for byte ordering, delivery bounds, queue compaction, interactive display coalescing, and presentation suspension/resume.

Testing

  • swift test --filter LocalProcessSchedulingTests
  • focused presentation/scheduling coverage: 7/7
  • swift test (701 tests across 60 suites)
  • git diff --check
  • CI green

Notes

This reduces and suspends bounded presentation work but does not claim a measured end-to-end latency improvement without runtime traces.

@migueldeicaza

Copy link
Copy Markdown
Owner

I redid the IO system in SwiftTerm in this branch, which will soon become the main branch (v2), please take it for a spin as it touches the same issues:

new-io-perf-glyph-cache

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.

2 participants