kworkflow / patch-hub

patch-hub is a TUI that streamlines the interaction of Linux developers with patches archived on lore.kernel.org
GNU General Public License v2.0
8 stars 6 forks source link

`patch-hub` consumes too much CPU even in release mode #87

Closed davidbtadokoro closed 4 days ago

davidbtadokoro commented 3 weeks ago

Description:

Even when running patch-hub in release mode, we can notice that the application consumes too much CPU for a simple TUI. I've seen occurrences where, while idling in a screen, the CPU consumption goes up to 30% (mind that in my setup I have 16 logical processors).

How to reproduce:

  1. Launch a system monitoring tool like htop
  2. Launch patch-hub in release mode with cargo run --release
  3. If in htop find the process and lock it with Shift+F
  4. Navigate through the tool and notice that there is some "unreasonable" CPU consumption

Expected behavior:

The problem resides in here, as we are rendering 60FPS. This design choice was made to avoid blocking the tool until a key event is captured. We could (1) reduce the framerate to something lower, as patch-hub surely doesn't need that many frames, or (2) eliminate this pooling, and block for each key event.

Approach 1 has the pro of reducing the CPU load (fewer frames to render per second), but, at least currently, patch-hub works the same with approach 2, while making it the most lightweight (which is what we expect from a TUI).

Screenshots

60FPS

highCPU

Blocking

blocking

Setup: