top: avoid '%Cpu' distortion resulting from keystrokes
Like a line from the movie Cool Hand Luke: "what we've
got here is failure to communicate"; well that was me!
Finally, I got a handle on the issue referenced below.
At first, it seemed inappropriate to try comparing cpu
percentages as reported by different top versions. And
even more so when they are invoked many seconds apart.
As it turns out, this issue had nothing to do with the
specific processor. Nor did it involve two versions of
top running simultaneously using the same delay value.
Rather, it concerns keyboard input and several changes
which were made last year in commits referenced below.
They were prompted by development of the 'Ctrl' bottom
window feature. Initially, if transitioning from a big
window to a small window portions of the former window
remained visible until the next refresh. A solution to
that led to a flaw when resizing top. Fixing that then
created a race condition with full screen replacement.
The net effect of all those changes was to distort the
cpu percentage value for the processor on which top is
dispatched to service user input. It arose because the
new frame was begun immediately, yielding few 'ticks'.
[ when fewer ticks are accumulated the potential for ]
[ distortion increases. As an example, hold some key ]
[ then watch cpu percentages (works best in graphs). ]
[ while any version of top will show distortions for ]
[ the above experiment, a v4.0.0 top will be greater ]
[ and %cpu is distorted even for a single keystroke. ]
So, to restore proper 3.3.17 keystroke behavior, we'll
revert parts of the first 3 commits shown below. Plus,
the 4th commit will be entirely reversed as redundant.
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/274
. Sep, 2022 - avoid potential 'BREAK_screen' race
commit
3e5016c2898d7129d2cdae7b1def8fe85d41619f
. Sep, 2022 - fix improper sigwinch behavior
commit
9d9993708b1854f7396b978a6d54d6c508e1fd08
. May, 2022 - made more responsive to kdb input
commit
3ea1bc779fb7ca5bf065a5ca620ec5b5823bc61c
. turn bottom window off with additional key
commit
3f068a66c84347a42fd27d8a809cea2656043b37
Signed-off-by: Jim Warner <james.warner@comcast.net>