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 commit3e5016c289
. Sep, 2022 - fix improper sigwinch behavior commit9d9993708b
. May, 2022 - made more responsive to kdb input commit3ea1bc779f
. turn bottom window off with additional key commit3f068a66c8
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
cbbe8fe324
commit
7e33fc47c6
@ -2144,6 +2144,7 @@ static void adj_geometry (void) {
|
|||||||
Graph_mems->style = Curwin->rc.graph_mems;
|
Graph_mems->style = Curwin->rc.graph_mems;
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
Frames_signal = BREAK_off;
|
||||||
} // end: adj_geometry
|
} // end: adj_geometry
|
||||||
|
|
||||||
|
|
||||||
@ -2477,7 +2478,6 @@ static void fields_utility (void) {
|
|||||||
|
|
||||||
spewFI
|
spewFI
|
||||||
signify_that:
|
signify_that:
|
||||||
Frames_signal = BREAK_off;
|
|
||||||
putp(Cap_clr_scr);
|
putp(Cap_clr_scr);
|
||||||
adj_geometry();
|
adj_geometry();
|
||||||
|
|
||||||
@ -3306,7 +3306,6 @@ static int insp_view_choice (struct pids_stack *p) {
|
|||||||
int key, curlin = 0, curcol = 0;
|
int key, curlin = 0, curcol = 0;
|
||||||
|
|
||||||
signify_that:
|
signify_that:
|
||||||
Frames_signal = BREAK_off;
|
|
||||||
putp(Cap_clr_scr);
|
putp(Cap_clr_scr);
|
||||||
adj_geometry();
|
adj_geometry();
|
||||||
|
|
||||||
@ -3429,7 +3428,6 @@ static void inspection_utility (int pid) {
|
|||||||
// must re-hide cursor since the prompt for a pid made it huge
|
// must re-hide cursor since the prompt for a pid made it huge
|
||||||
putp((Cursor_state = Cap_curs_hide));
|
putp((Cursor_state = Cap_curs_hide));
|
||||||
signify_that:
|
signify_that:
|
||||||
Frames_signal = BREAK_off;
|
|
||||||
putp(Cap_clr_scr);
|
putp(Cap_clr_scr);
|
||||||
adj_geometry();
|
adj_geometry();
|
||||||
|
|
||||||
@ -4613,7 +4611,6 @@ static void wins_colors (void) {
|
|||||||
wins_clrhlp(w, 1);
|
wins_clrhlp(w, 1);
|
||||||
putp((Cursor_state = Cap_curs_huge));
|
putp((Cursor_state = Cap_curs_huge));
|
||||||
signify_that:
|
signify_that:
|
||||||
Frames_signal = BREAK_off;
|
|
||||||
putp(Cap_clr_scr);
|
putp(Cap_clr_scr);
|
||||||
adj_geometry();
|
adj_geometry();
|
||||||
|
|
||||||
@ -5268,6 +5265,8 @@ static void bot_item_toggle (int what, const char *head, char sep) {
|
|||||||
if (Bot_what == what) {
|
if (Bot_what == what) {
|
||||||
BOT_TOSS;
|
BOT_TOSS;
|
||||||
} else {
|
} else {
|
||||||
|
// accommodate transition from larger to smaller window
|
||||||
|
Bot_rsvd = 0;
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case BOT_ITEM_NS:
|
case BOT_ITEM_NS:
|
||||||
for (i = 0; i < MAXTBL(ns_tab); i++)
|
for (i = 0; i < MAXTBL(ns_tab); i++)
|
||||||
@ -5363,7 +5362,6 @@ static void help_view (void) {
|
|||||||
|
|
||||||
putp((Cursor_state = Cap_curs_huge));
|
putp((Cursor_state = Cap_curs_huge));
|
||||||
signify_that:
|
signify_that:
|
||||||
Frames_signal = BREAK_off;
|
|
||||||
putp(Cap_clr_scr);
|
putp(Cap_clr_scr);
|
||||||
adj_geometry();
|
adj_geometry();
|
||||||
|
|
||||||
@ -5388,7 +5386,6 @@ signify_that:
|
|||||||
case '?': case 'h': case 'H':
|
case '?': case 'h': case 'H':
|
||||||
do {
|
do {
|
||||||
signify_this:
|
signify_this:
|
||||||
Frames_signal = BREAK_off;
|
|
||||||
putp(Cap_clr_scr);
|
putp(Cap_clr_scr);
|
||||||
adj_geometry();
|
adj_geometry();
|
||||||
show_special(1, fmtmk(N_unq(WINDOWS_help_fmt)
|
show_special(1, fmtmk(N_unq(WINDOWS_help_fmt)
|
||||||
@ -5582,8 +5579,6 @@ static void keys_global (int ch) {
|
|||||||
Winstk[i].begtask = Winstk[i].focus_pid = 0;
|
Winstk[i].begtask = Winstk[i].focus_pid = 0;
|
||||||
// force an extra procs refresh to avoid %cpu distortions...
|
// force an extra procs refresh to avoid %cpu distortions...
|
||||||
Pseudo_row = PROC_XTRA;
|
Pseudo_row = PROC_XTRA;
|
||||||
// signal that we just corrupted entire screen
|
|
||||||
Frames_signal = BREAK_screen;
|
|
||||||
break;
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
if (Cpu_cnt > 1) {
|
if (Cpu_cnt > 1) {
|
||||||
@ -7360,7 +7355,6 @@ int main (int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (0 < Loops) --Loops;
|
if (0 < Loops) --Loops;
|
||||||
if (!Loops) bye_bye(NULL);
|
if (!Loops) bye_bye(NULL);
|
||||||
if (Frames_signal) { Frames_signal = BREAK_off; zap_fieldstab(); continue; }
|
|
||||||
|
|
||||||
ts.tv_sec = Rc.delay_time;
|
ts.tv_sec = Rc.delay_time;
|
||||||
ts.tv_nsec = (Rc.delay_time - (int)Rc.delay_time) * 1000000000;
|
ts.tv_nsec = (Rc.delay_time - (int)Rc.delay_time) * 1000000000;
|
||||||
|
Loading…
Reference in New Issue
Block a user