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