darwin: lazily set process TTY name

Fetching the TTY name of a process is extremely expensive on darwin and
the call to devname accounts for 95% of htop's CPU usage when there is
high process turnover (this is mostly due to devname calling lstat,
which is incredibly slow). This can make htop unresponsive.

To mitigate this only set the process TTY name if the it is being
actively displayed (PROCESS_FLAG_TTY), which by default it is not
on darwin.
This commit is contained in:
Charlie Vieth
2022-02-04 11:21:13 -05:00
committed by BenBE
parent 978a7c894f
commit d35db47c9a
2 changed files with 34 additions and 9 deletions

View File

@ -13,6 +13,8 @@ in the source distribution for its full text.
#include "darwin/DarwinProcessList.h"
#define PROCESS_FLAG_TTY 0x00000100
typedef struct DarwinProcess_ {
Process super;