aaronjanse / 3mux

Terminal multiplexer inspired by i3
MIT License
1.82k stars 45 forks source link

optimise rendering latency and efficiency #106

Closed aaronjanse closed 3 years ago

aaronjanse commented 3 years ago

On my laptop, this reduces idle CPU usage from 3% to 0%. It also reduces rendering latency in many cases.

Currently, the global renderer continually scans the entire pendingScreen to see if anything has changed, rendering frame-by-frame. In this PR, when the renderer detects a series of frames without changes, it uses a queue to render characters immediately once they're received. When the queue gets too long, the renderer switches back to frame-based rendering. This is similar to how tmux works. See the comments on RenderViaQueue and RenderViaFrames for more information.

In addition to optimizing the global renderer, I made some optimizations in wm/ and vterm/. Without them, the global renderer has many "high-throughput mode" false-positives. If wanted, I could put these changes in a separate PR.