tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: optimize ps(1) for slow machines



On 2016/11/28 16:20, Martin Husemann wrote:
On Sun, Nov 27, 2016 at 05:05:47PM +0900, Rin Okuyama wrote:
ps(1) is very slow on old machines when its output is sorted by CPU
usage. This is because it calculate CPU usage of two processes using
exp(3) and log(3) every time when it compare them in qsort(3). This
means that it carries out expensive floating-point arithmetic
O[N log(N)] times when N processes are shown.

Here, I attached a patch where

(1) CPU usage is calculated only once per process
(2) do not call log(3) in CPU usage calculations

This significantly improves performance on, e.g., a m68k box without
FPU. In addition, I did

(3) in donlist{,_sysctl}, use common default values and warn user
appropriately when an error occurs

Can I commit this? Any suggestions or comments?

Looks good to me.

Thanks, committed!

Rin


Home | Main Index | Thread Index | Old Index