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