Hi tech@,

I want to suggest a small convenience (for me at least) change to top(1):

- Always start with combined cpu stats view (one line)

Supporting changes:
- Invert behaviour of "top -1" accordingly
- Remove then unnecessary "if cpus > 8 then combined_view = 1"
- Adjust man page accordingly
- Correct built-in help page accordingly


Rationale:

I don't know about the rest of you, but personally I almost always want
to see the combined CPU statistics on top of top's (pun not intended)
display page.

If there's a process stuck in a loop or something I might want to break
the display out to show separate cores but otherwise I prefer to use
maximum real estate for the process list.


I know there's an "if more than eight processors, then start with
combined cpu" clause, but my muscle memory likes a consistent behaviour.
Not that running "top -1" is a big nuisance, but still...

Besides, the number eight feels kind of arbitrary to me. I mean, if the
default behaviour is going to be dynamically decided anyway, why not
base it on for example the number of available screen lines?


If I'm not the only one who would like this, here's a diff.


Regards,

/Benny



(I hope my Thunderbird doesn't mangle the diff, a couple of lines are
>80 characters.)


Index: display.c
===================================================================
RCS file: /cvs/src/usr.bin/top/display.c,v
retrieving revision 1.50
diff -u -p -r1.50 display.c
--- display.c   26 Oct 2015 12:44:22 -0000      1.50
+++ display.c   6 Nov 2015 13:28:55 -0000
@@ -804,7 +804,7 @@ show_help(void)
            "^L           - redraw screen\n"
            "<space>      - update screen\n"
            "+            - reset any g, p, or u filters\n"
-           "1            - display CPU statistics on a single line\n"
+           "1            - toggle display of combined (one line) or
per-CPU statistics\n"
            "C            - toggle the display of command line arguments\n"
            "d count      - show `count' displays, then exit\n"
            "e            - list errors generated by last \"kill\" or
\"renice\" command\n"
Index: top.1
===================================================================
RCS file: /cvs/src/usr.bin/top/top.1,v
retrieving revision 1.66
diff -u -p -r1.66 top.1
--- top.1       6 May 2015 07:53:29 -0000       1.66
+++ top.1       6 Nov 2015 13:28:55 -0000
@@ -75,10 +75,9 @@ terminal.
 The options are as follows:
 .Bl -tag -width Ds
 .It Fl 1
-Display combined CPU statistics for all processors on a single line
-instead of one line per CPU.
-If there are more than 8 CPUs detected in the system this option
-is automatically enabled.
+Display CPU usage statistics split on one line per processor.
+Default is to display combined statistics for all processors
+on a single line.
 .It Fl b
 Use
 .Em batch
Index: top.c
===================================================================
RCS file: /cvs/src/usr.bin/top/top.c,v
retrieving revision 1.88
diff -u -p -r1.88 top.c
--- top.c       5 Nov 2015 17:17:13 -0000       1.88
+++ top.c       6 Nov 2015 13:28:55 -0000
@@ -83,7 +83,7 @@ int old_system = No;
 int old_threads = No;
 int show_args = No;
 pid_t hlpid = -1;
-int combine_cpus = 0;
+int combine_cpus = 1;

 #if Default_TOPN == Infinity
 char topn_specified = No;
@@ -139,7 +139,7 @@ parseargs(int ac, char **av)
        while ((i = getopt(ac, av, "1SHICbinqus:d:p:U:o:g:")) != -1) {
                switch (i) {
                case '1':
-                       combine_cpus = 1;
+                       combine_cpus = !combine_cpus;
                        break;
                case 'C':
                        show_args = Yes;
@@ -253,9 +253,6 @@ parseargs(int ac, char **av)
        i = getncpu();
        if (i == -1)
                err(1, NULL);
-
-       if (i > 8)
-               combine_cpus = 1;

        /* get count of top processes to display (if any) */
        if (optind < ac) {

Reply via email to