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