5cc68e
This file summarizes changes to the top program and supporting documentation
5cc68e
introduced on March 31, 2011.
5cc68e
5cc68e
Contents:
5cc68e
      DOCUMENT Changes
5cc68e
      INTERNAL Improvements
5cc68e
      EXTERNAL Improvements
5cc68e
      BUGS Previously Fixed and Preserved
5cc68e
      BUGS Newly/Nearly Fixed
5cc68e
      BUGS/WISH-LISTS That Should Go Bye-bye
5cc68e
      BUGS FIXED You Didn't Know You Had
5cc68e
      OTHER Changes, Hopefully They Won't Bite You
5cc68e
      BENCHMARKS
5cc68e
5cc68e
5cc68e
DOCUMENT Changes =========================================================
5cc68e
  . The entire file was cleaned up, standardized and expanded to include:
5cc68e
    - a new section "2. SUMMARY Display" added for symmetry with Fields
5cc68e
    - nine new fields were added to section "3a. DESCRIPTIONS of Fields"
5cc68e
    - a new section "3b. MANAGING Fields" replaced the obsolete section
5cc68e
      "2b. SELECTING and ORDERING Columns"
5cc68e
    - section "5c. SCROLLING a Window" was added for that new feature
5cc68e
5cc68e
  . I don't know when the explanations for CODE and DATA were changed to
5cc68e
    show 'virtual' memory, but I think there's a reason their alternate
5cc68e
    names contain the word 'resident'.  Thus they were changed back to
5cc68e
    say 'physical memory'.
5cc68e
5cc68e
  . And as I indicated in a previous email, the former string identifier
5cc68e
    'ME' was restored as were the 'h' key/command conventions (vs. <h>).
5cc68e
5cc68e
    Oops, the 'h' key/command conventions remain restored, but subsequent
5cc68e
    testing revealed problems with the .ME string identifier.  Thus, it was
5cc68e
    changed to .WE (along with the companion .Me/.We id).
5cc68e
5cc68e
  . Also previously mentioned, the 'man2html' program translates top.1 to
5cc68e
    HTML with near perfect fidelity.  I take that to mean there should be
5cc68e
    no problems with the top.1 source on most other platforms.
5cc68e
5cc68e
    To further improve translation to HTML, several .Bd and .Ed macros
5cc68e
    were added to preserve literal (fixed width) spacing.
5cc68e
5cc68e
5cc68e
INTERNAL Improvements ====================================================
5cc68e
  . The old restriction of 26 fields has been lifted.  With this new-top
5cc68e
    100+ fields are now possible.  It currently supports up to 55, of
5cc68e
    which 35 are in use.  Adding a new field is almost too easy.
5cc68e
5cc68e
  . Task row construction has been considerably improved -- both from
5cc68e
    a programming perspective and a performance perspective.
5cc68e
5cc68e
  . The column highlighting costs for sort field visibility were
5cc68e
    virtually eliminated.
5cc68e
5cc68e
    An optional define (USE_X_COLHDR) can be enabled to completely
5cc68e
    eliminate any costs associated with the 'x' command toggle.
5cc68e
5cc68e
  . The management of the HST_t structures, used for %cpu calculations,
5cc68e
    was optimized with a hashing scheme.  Thus the need for a qsort then
5cc68e
    a binary search in each frame was completely eliminated.
5cc68e
5cc68e
    An optional define can restore the former qsort/bsearch approach but
5cc68e
    with an internal inlined binary search function offering substantially
5cc68e
    better performance than the old top.
5cc68e
5cc68e
  . This far more capable new-top executable is no larger than old top.
5cc68e
5cc68e
  . The above combine to produce substantially improved performance
5cc68e
    whose details are documented below under BENCHMARKS.
5cc68e
5cc68e
5cc68e
EXTERNAL Improvements ====================================================
5cc68e
  . Field management has been completely redesigned.  It's now embodied
5cc68e
    on a single screen where display-ability, position and sort selection
5cc68e
    can be handled in one place -- for all windows at one time!
5cc68e
5cc68e
    This function is dependent on cursor motion keys and should a device
5cc68e
    not have the customary arrow keys, alternatives are provided and
5cc68e
    documented under "Operation" near the beginning of the man page.
5cc68e
5cc68e
  . The following new fields have been added:
5cc68e
       Group Id
5cc68e
       Minor Page Faults
5cc68e
       Number of Threads
5cc68e
       Process Group Id
5cc68e
       Real User Id
5cc68e
       Saved User Id
5cc68e
       Saved User Name
5cc68e
       Session Id
5cc68e
       Tty Process Group Id
5cc68e
5cc68e
  . Scrolling keys now allow one to move the view of any window vertically
5cc68e
    or horizontally to reveal any desired task or column.  Previously, only
5cc68e
    some tasks were viewable even with reversible, selectable sort columns.
5cc68e
5cc68e
    Each of the four windows is capable of maintaining its own scrolled
5cc68e
    coordinates and an optional toggle ('C') displays a message aiding
5cc68e
    navigation within the available tasks and displayable fields.
5cc68e
5cc68e
  . User interactive line oriented input now provides for true line
5cc68e
    editing supported by these new keys:
5cc68e
        Left/Right arrow keys, Delete key, Backspace and
5cc68e
        Home/End keys (likely limited to xterm, not terminal)
5cc68e
5cc68e
  . User filtering via the -u | -U interactive commands is now window
5cc68e
    based which means that different windows could be used to filter
5cc68e
    different users.
5cc68e
5cc68e
  . Signal handling has been normalized and is now consistent regardless
5cc68e
    of the particular top screen a user may have been using.
5cc68e
5cc68e
  . The 'i' toggle now shows any task that has used *some* cpu since the
5cc68e
    last screen update.  It's no longer limited to just running tasks.
5cc68e
5cc68e
  . The summary area 'task states' line now reflects either 'Threads'
5cc68e
    or 'Tasks' depending on the -H toggle.
5cc68e
5cc68e
5cc68e
BUGS Previously Fixed and Preserved ======================================
5cc68e
  ( but not necessarily literally)
5cc68e
  . 228822, suspending top leaves xterm in slightly messed-up state
5cc68e
  . 256376, segfaults, if the xterm is to small
5cc68e
  . 320289, segv on sigwinch
5cc68e
  . 351065, wrong highlight 1st column (escape characters displayed)
5cc68e
  . 358724, accepts extra numeric args
5cc68e
  . 378695, seg fault if "/proc" is not mounted
5cc68e
  . 426782, UID field is too narrow
5cc68e
  . 458986, should check xterm for EOF/EIO
5cc68e
  . 459890, Irix mode should use %#4.1f when threads shown
5cc68e
5cc68e
5cc68e
BUGS Newly/Nearly Fixed ==================================================
5cc68e
  . 225542, 'Unknown command' message blocks further commands
5cc68e
      The message is now displayed using usleep for 1.25 seconds, instead
5cc68e
      of the former full 2 seconds.  And while it still blocks further
5cc68e
      commands, the delay is much more tolerable.
5cc68e
5cc68e
      Can we consider this bug 'nearly' fixed?
5cc68e
5cc68e
  . 410292, interface error when using backspace
5cc68e
      Full line editing was added but could be disabled via a #define.
5cc68e
      And via that define, even under basic termios support, the backspace
5cc68e
      problem was cured.
5cc68e
5cc68e
  . 567509, top idle command ('i') not working for threaded programs
5cc68e
      Since the 'i' command now reflects tasks that have used *some* cpu,
5cc68e
      and is no longer dependent on an 'R' state, I *believe/hope* this
5cc68e
      bug has been swatted.
5cc68e
5cc68e
5cc68e
BUGS/WISH-LISTS That Should Go Bye-bye ===================================
5cc68e
  . 340751, wish for hostname to benefit multiple top sessions
5cc68e
      Craig's suggestion regarding symlinks is the perfect solution.
5cc68e
      How dare Craig say that the solution was "not ideal" !
5cc68e
5cc68e
  . 586497, wish for graceful degradation on small screen sizes
5cc68e
      This objective could be accomplished by setting up 2 symlinks for
5cc68e
      top, personalizing them for the 2 tiny phone displays, then writing
5cc68e
      the respective configuration files.
5cc68e
5cc68e
      I shudder at the programming effort suggested by Paul.  And when it
5cc68e
      was done you'd find everybody else would have different criteria.
5cc68e
5cc68e
5cc68e
BUGS FIXED You Didn't Know You Had =======================================
5cc68e
  . Without amplifying the dirty details, the long standing occasionally
5cc68e
    reported display corruption, and an unreported source of performance
5cc68e
    degradation, has been eliminated.  The cure is in the elimination of
5cc68e
    the Pseudo_cols variable and the improved PUFF macro.
5cc68e
5cc68e
  . Line oriented input was not sensitive to screen width.  Thus a user
5cc68e
    could hold down any key and ultimately line wrap, overwriting the
5cc68e
    columns header and the entire screen.  New top prevents this.
5cc68e
5cc68e
  . User filtering (-u|-U) via a user ID (not name) now validates that
5cc68e
    number.  The old-top just made sure it was numeric, then blindly
5cc68e
    displayed no matching users (i.e. an empty window).
5cc68e
5cc68e
  . The threads toggle ('H') is no longer window based but more properly
5cc68e
    applies to all windows.  The previous implementation produced the
5cc68e
    following aberration if multiple windows were being shown:
5cc68e
      . -H would be acknowledged and applied to all visible windows
5cc68e
      . keying 'a' or 'w' would silently turn it off
5cc68e
      . then keying -H would turn it back on, but the user expected off
5cc68e
5cc68e
  . If you hit ^Z on any help or fields screen to suspend old-top, after
5cc68e
    issuing 'fg' you would then be left with a seemingly hung application
5cc68e
    inviting ^C.  In truth, one could recover with the space bar, but that
5cc68e
    was far from intuitive.
5cc68e
5cc68e
  . The old-top consistently writes 1 extra byte for each task row or 1
5cc68e
    byte too few for columns headers, depending on your perspective.
5cc68e
    The new top writes the same number of bytes for each.
5cc68e
5cc68e
  . By failing to clear to eol, old top left the display in a terrible
5cc68e
    state after exiting a 'fields' screen when only a few columns were
5cc68e
    being displayed.
5cc68e
5cc68e
  . The old-top used a zero value for the L_NONE library flag which could
5cc68e
    cause repeated rebuilding of columns headers with each frame.  In truth,
5cc68e
    this was not likely to happen in real life since only two fields actually
5cc68e
    used that flag.  However, if it did happen, performance could be degraded
5cc68e
    by 800%.
5cc68e
5cc68e
5cc68e
OTHER Changes, Hopefully They Won't Bite You =============================
5cc68e
  . The undocumented TOPRC environment variable is no longer supported.
5cc68e
    Any similar need can be met through a symlink alias.
5cc68e
5cc68e
  . The use of environment variables to override terminal size is now
5cc68e
    off by default but could be enabled through '#define TTYGETENVYES'.
5cc68e
5cc68e
  . The global 'bold enable' toggle is active by default and thus agrees
5cc68e
    with the documentation.  It's been wrong ever since Al's wholesale
5cc68e
    'cosmetic' changes in procps-3.2.2.
5cc68e
5cc68e
  . Task defaults now show bold (not reverse) and row highlighting.
5cc68e
    This agrees with what was always stated in the documentation.
5cc68e
5cc68e
  . The 'H' toggle (thread mode) is not persistent.  Persistence can be
5cc68e
    achieved with a simple shell script employing the -H switch.
5cc68e
5cc68e
  . Then 'g' and 'G' commands were reversed to reflect their likely use.
5cc68e
5cc68e
5cc68e
BENCHMARKS ===============================================================
5cc68e
  Tested as root with nice -10 and using only common fields
5cc68e
   ( on a pretty old, slow laptop under Debian Lenny )
5cc68e
  but rcfiles specified identical sort fields and identical
5cc68e
  settings for the 'B', 'b', 'x' and 'y' toggles (even though
5cc68e
  the defaults are not necessarily identical).
5cc68e
5cc68e
  In every case new-top outperforms old-top, but I've shown %
5cc68e
  improvements for only the most significant.  Those cases mostly
5cc68e
  involve colors with both row & column highlighting.  I suggested
5cc68e
  above that the highlighting cost was virtually eliminated in
5cc68e
  new-top, and these tests bare that out.
5cc68e
5cc68e
  Note the much smaller differences for new-top between the 24x80
5cc68e
  window results and full screen (but don't mix apples_terminal
5cc68e
  with oranges_xterm).  This is a reflection of the simplification
5cc68e
  of task row construction, also mentioned above.
5cc68e
5cc68e
  It's always been the case that any top in an xterm outperforms
5cc68e
  that top under the terminal application, even when the xterm
5cc68e
  provides additional rows and columns.  It's true below with
5cc68e
  Gnome and it was true nine years ago under KDE.
5cc68e
5cc68e
  ----------------------------------------------------------
5cc68e
   The following comparisons were run with:
5cc68e
      100 tasks & 160 threads
5cc68e
      -d0 -n5000
5cc68e
                                 new-top        old-top
5cc68e
  xterm     24x80
5cc68e
 a  1 win,  lflgs_none         11.2 secs      51.8 secs    + 462.6%
5cc68e
    1 win,  default            61.0 secs      66.8 secs
5cc68e
    1 win,  colors w/ x+y      61.3 secs      83.0 secs    + 135.4%
5cc68e
    1 win,  thread mode        88.3 secs      94.2 secs
5cc68e
 b  1 win,  every field on     99.7 secs     106.0 secs
5cc68e
    1 win,  cmdline            71.2 secs      76.6 secs
5cc68e
    4 wins, defaults          101.3 secs     107.2 secs
5cc68e
    4 wins, colors w/ x+y     101.5 secs     122.8 secs    + 121.0%
5cc68e
5cc68e
  xterm, full screen (53x170)
5cc68e
 a  1 win,  lflgs_none         15.9 secs      54.2 secs    + 340.9%
5cc68e
    1 win,  default            70.0 secs      73.2 secs
5cc68e
    1 win,  colors w/ x+y      69.4 secs     131.3 secs    + 189.2%
5cc68e
    1 win,  thread mode        97.6 secs     102.6 secs
5cc68e
 c  1 win,  every field on    122.1 secs     128.1 secs
5cc68e
    1 win,  cmdline            80.8 secs      83.7 secs
5cc68e
    4 wins, defaults          111.4 secs     115.8 secs
5cc68e
    4 wins, colors w/ x+y     112.0 secs     172.9 secs    + 154.4%
5cc68e
5cc68e
  terminal  24x80
5cc68e
 a  1 win,  lflgs_none          8.9 secs      58.6 secs    + 658.4%
5cc68e
    1 win,  default            70.1 secs      80.3 secs
5cc68e
    1 win,  colors w/ x+y      70.6 secs     157.3 secs    + 222.8%
5cc68e
    1 win,  thread mode       104.7 secs     120.5 secs
5cc68e
 b  1 win,  every field on    111.2 secs     134.5 secs
5cc68e
    1 win,  cmdline            83.8 secs      94.5 secs
5cc68e
    4 wins, defaults          125.6 secs     146.7 secs
5cc68e
    4 wins, colors w/ x+y     125.6 secs     206.9 secs    + 176.7%
5cc68e
5cc68e
  terminal, full screen (39x125)
5cc68e
 a  1 win,  lflgs_none          9.1 secs      60.6 secs    + 665.9%
5cc68e
    1 win,  default            74.3 secs      88.0 secs
5cc68e
    1 win,  colors w/ x+y      73.9 secs     314.5 secs    + 425.6%
5cc68e
    1 win,  thread mode       113.0 secs     140.9 secs
5cc68e
 b  1 win,  every field on    117.7 secs     154.9 secs
5cc68e
    1 win,  cmdline            87.4 secs     107.2 secs
5cc68e
    4 wins, defaults          139.1 secs     166.7 secs
5cc68e
    4 wins, colors w/ x+y     157.3 secs     423.2 secs    + 269.0%
5cc68e
5cc68e
  ----------------------------------------------------------
5cc68e
   The following comarisons were run with:
5cc68e
      300 tasks & 360 threads
5cc68e
      -d0 -n3000
5cc68e
                                 new-top        old-top
5cc68e
  xterm, full screen (53x170)
5cc68e
 a  1 win,  lflgs_none         14.3 secs      79.0 secs    + 552.4%
5cc68e
    1 win,  default           101.1 secs     104.5 secs
5cc68e
    1 win,  colors w/ x+y     101.3 secs     140.0 secs    + 138.2%
5cc68e
    1 win,  thread mode       120.1 secs     123.1 secs
5cc68e
 c  1 win,  every field on    179.8 secs     185.6 secs
5cc68e
    1 win,  cmdline           124.9 secs     132.8 secs
5cc68e
    4 wins, defaults          174.8 secs     179.2 secs
5cc68e
    4 wins, colors w/ x+y     175.0 secs     215.2 secs    + 123.0%
5cc68e
5cc68e
  terminal, full screen (39x125)
5cc68e
 a  1 win,  lflgs_none         12.3 secs      98.5 secs    + 800.8%
5cc68e
    1 win,  default           117.4 secs     134.0 secs
5cc68e
    1 win,  colors w/ x+y     111.6 secs     296.1 secs    + 265.3%
5cc68e
    1 win,  thread mode       141.3 secs     155.3 secs
5cc68e
 b  1 win,  every field on    197.7 secs     204.8 secs
5cc68e
    1 win,  cmdline           143.9 secs     157.3 secs
5cc68e
    4 wins, defaults          204.0 secs     226.2 secs
5cc68e
    4 wins, colors w/ x+y     216.9 secs     434.5 secs    + 200.3%
5cc68e
5cc68e
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5cc68e
5cc68e
notes:
5cc68e
 a  these results represent the library flags L_NONE zero value and
5cc68e
    thus the hidden cost of rebuilding column headers w/ every frame
5cc68e
 b  while every common field was turned on, not all fields could be
5cc68e
    displayed due to limited screen width
5cc68e
 c  only in a full screen xterm window could all common fields
5cc68e
    actually be displayed
5cc68e
5cc68e
5cc68e
BENCHMARKS, Redux (for NLS) ==============================================
5cc68e
  December, 2011 benchmarks produced on a much more modern
5cc68e
  platform containing:
5cc68e
     Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz
5cc68e
     SMP with 4 cpus
5cc68e
  reflected in the substantially reduced elapsed times.
5cc68e
5cc68e
  Tested as root with nice -10 and using only common fields
5cc68e
  but rcfiles specified identical sort fields and identical
5cc68e
  settings for the 'B', 'b', 'x' and 'y' toggles (even though
5cc68e
  the defaults are not necessarily identical).
5cc68e
5cc68e
  Each test was run outside of X-windows at a linux console
5cc68e
  offering 48 rows and 170 columns.  This was done to reduce
5cc68e
  contention which sometimes made comparisons problematic.
5cc68e
5cc68e
  old-top = procps-3.2.8 (debian patched and memory leaking)
5cc68e
  new-top = procps-ng-3.3.2 with NLS support
5cc68e
5cc68e
  ----------------------------------------------------------
5cc68e
   The following comparisons were run with
5cc68e
      -d0 -n5000
5cc68e
      140 tasks & 275 threads
5cc68e
5cc68e
  linux console (48x170)         new-top        old-top
5cc68e
 d  1 win,  lflgs_none          2.6 secs      15.0 secs    + 577.0%
5cc68e
    1 win,  default            16.1 secs      19.3 secs
5cc68e
    1 win,  colors w/ x+y      16.6 secs      35.0 secs    + 210.8%
5cc68e
 e  1 win,  show cpus          16.2 secs      20.1 secs    + 124.1%
5cc68e
    1 win,  thread mode        31.8 secs      34.1 secs
5cc68e
 f  1 win,  every field on     30.5 secs      34.0 secs
5cc68e
    1 win,  cmdline            19.9 secs      23.1 secs
5cc68e
    4 wins, default            31.9 secs      35.2 secs
5cc68e
    4 wins, colors w/ x+y      29.2 secs      47.4 secs    + 162.3%
5cc68e
 g  1 win,  b&w w/ bold x      30.0 secs      33.2 secs
5cc68e
 h  1 win,  scroll msg on      31.1 secs      33.9 secs
5cc68e
5cc68e
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5cc68e
5cc68e
notes:
5cc68e
 d  these represent the same anamoly as the original 'a' footnote
5cc68e
 e  these represent the '1' toggle, where each of 4 cpus was shown
5cc68e
      (not possible on the original uniprocessor)
5cc68e
 f  every common field was turned on and all fields were visible
5cc68e
 g  on a black and white display, sort column was shown in bold
5cc68e
      (further proof of column highlighting improvements)
5cc68e
 h  similar to 'g', but new top was showing scroll msg
5cc68e
      (old top has no such provision)