liamg / darktile

:waning_crescent_moon: Darktile is a GPU rendered terminal emulator designed for tiling window managers.
MIT License
3.04k stars 112 forks source link

Avoid polling in main GUI loop #245

Closed mjs closed 5 years ago

mjs commented 5 years ago

Description

Instead of waking up regularly using WaitEventsTimeout, WaitEvents and PostEmptyEvent are used to make the main loop event driven. The maximum rate of redraws due to terminal activity can be tweaked via the new wakePeriod const.

This leads to some significant performance improvements: Aminal now consumes:

This change also incidentally fixes data races around the terminal dirty flag (which is now gone).

Type of change

How Has This Been Tested?

This has seen extensive manual testing on Windows and Linux using cmd.exe, Windows SSH to Linux host, zsh and bash on Linux.

Test Configuration:

Checklist:

rrrooommmaaa commented 5 years ago

@mjs Why didn't you put dirty notifier to TerminalState? Terminal and buffer share this object already. No need for extra argument in constructor. @MaxRis I suggest we optimize this

maxhora commented 5 years ago

@rrrooommmaaa will it be fine to add improvements as new separate PR?

mjs commented 5 years ago

@rrrooommmaaa I considered putting dirty onto TerminalState but given that the dirty state was set for several conditions that don't involve a change to TerminalState it didn't seem like the right place for it.

I'm happy to revisit this later if you think it's worthwhile.

rrrooommmaaa commented 5 years ago

@mjs What conditions? Can you give examples, please?