Commit Graph

32 Commits

Author SHA1 Message Date
rstone
5cabc5d61e Add a dtrace script for collecting schedgraph data 2016-11-18 02:29:09 +00:00
rodrigc
b75981aabc Use print as a function for Python 3 [PEP 3105]
Import print_function from the __future__ module
to activate this for Python 2.  This works as far back as Python 2.6.0a2:
   https://docs.python.org/2/library/__future__.html

[PEP 3105] https://www.python.org/dev/peps/pep-3105/
2015-11-19 00:01:52 +00:00
rodrigc
0faa3804ef Use 'in' instead of 'has_key()' for testing dictionary membership.
In PEP 0290, has_key() was deprecated in Python 2.2 and higher:
https://www.python.org/dev/peps/pep-0290/#testing-dictionary-membership
https://docs.python.org/2.2/whatsnew/node4.html

In Python 3, dict.has_key() was removed:
https://docs.python.org/3.0/whatsnew/3.0.html#builtins
2015-11-18 23:32:29 +00:00
jhb
abae099c34 Add a new thread state "spinning" to schedgraph and add tracepoints at the
start and stop of spinning waits in lock primitives.
2014-11-04 16:35:56 +00:00
jhb
0b0514e889 Bind Ctrl-Q as a global hotkey to exit. Bind Ctrl-W as a hotkey to close
dialogs.
2014-11-04 16:30:42 +00:00
jhb
877e018654 Add schedgraph traces for callout handlers. Specifically, a callwheel logs
a running event each time it executes a callout function.  The event
includes the function pointer, argument, and whether or not it was run from
hardware interrupt context.  The callwheel is marked idle when each handler
completes.  This effectively logs the duration of each callout routine in
the graph.
2014-10-08 16:22:59 +00:00
jhb
0410aaa991 Explicitly return None for negative event indices. Prior to this,
eventat(-1) would return the next-to-last event causing the back button
to cycle back to the end of an event source instead of stopping at the
start.
2014-09-30 17:19:07 +00:00
jeff
a921977684 - Update my copyright.
- Print human readable time as a float with two digits of precision.  Use
   ns now as well since clock periods are well into the hundreds of
   picoseconds now.
 - Show the average duration in the stats frame.  This is often more useful
   than total duration.
2009-01-22 06:21:30 +00:00
jeff
802c315606 - Permit timestamps to be as far as 2048 ticks apart before we complain
about invalid timestamps.  Nehalem CPUs seem to be synchronized but only
   within a fraction of a microsecond.
 - Make the Counter code more flexible to poor timestamps.  In general we
   now complain a lot but render as much as we can.
 - Change the scaler behavior so it works better with very long and very
   short traces.  We now set the maximum scale such that it properly
   displays the entire file by default and doesn't permit zooming out
   beyond the file.  This improves other awkward navigation behavior.
   The interval is now set very small which can't be achieved by simply
   dragging the mouse.  Clicking to the left of or right of the scaler bar
   will produce increments of a single, very small, interval now.

Sponsored by:   Nokia
2009-01-20 12:33:04 +00:00
jeff
5d9daf6331 - Add summary information to the title once the file is parsed rather than
printing it to the terminal.  Now only parse errors go to the terminal.
 - Speedup drawing by raising and lowering tags only once everything has
   been drawn.  Surprisingly, it now takes a little longer to parse than
   it does to draw.
 - Parameterize the layout with X_ and Y_ defines that determine the sizes
   of various things.
 - Remove unnecessary tags.
2009-01-18 05:44:31 +00:00
jeff
1d6fbb62ea - Significantly speedup hiding and displaying multiple rows by writing an
optimized single pass function for each.  This reduces the number of
   tkinter calls required to the minimum.
 - Add a right-click context menu for sources.  Supported commands hide
   the source, hide the whole group the source is in, and bring up a stat
   window.
 - Add a source stat frame that gives an event frequency table as well as
   the total duration for each event type that has a duration.  This can
   be used to see, for example, the total time a thread spent running or
   blocked by a wchan or lock.
2009-01-18 04:49:01 +00:00
jeff
469b3b8461 - Add a new source configuration menu option that allows hiding and
displaying sources.
 - Add functions to the main SchedGraph to facilitate source hiding.  The
   source is simply moved off screen and all other sources are moved to
   compensate.
2009-01-17 11:19:15 +00:00
jeff
da5ccad246 - Rewrite the parser to support the new generic schedgraph interface.
This no longer requires any custom classes or parsers to support new
   event types.
 - Add an optional command line argument for specifying the clock frequency
   in ghz.  This is useful for traces that do not include KTR_SCHED.

Sponsored by:	Nokia

 - Add support for sorting rows by clicking and dragging them to their new
   position.
 - Add support for configuring the cpu background colors.
 - Improve the scaling so a better center is maintained as you zoom.  This
   is not perfect due to precision loss with floats used in the window
   views.
 - Add new colors and a random assignment for unknown event types.  A table
   is used for known event types.  This is the only event specific
   information.
2009-01-17 07:24:25 +00:00
jhb
43a484c528 Add support for two new event source types:
- Callwheels traced via KTR_CALLOUT.  Each CPU is assigned a callwheel
  source.  The events on this source are the execution of individual callout
  routines.  Each routine shows up as a green rectangle while it is executed
  and the event details include the function pointer and argument.
- Locks traced via KTR_LOCK.  Currently, each lock name is assigned an event
  source (since the existing KTR_LOCK traces only include lock names and
  not pointers).  This does mean that if multiple locks of the same name are
  manipulated, the source line for that name may be confusing.  However, for
  many cases this can be useful.  Locks are blue when they are held and
  purple when contested.  The contention support is a bit weak due to
  limitations in the rw_rlock() and mtx_lock_spin() logging messages
  currently.  I also have not added support for contention on lockmgr,
  sx, or rmlocks yet.  What is there now can be profitably used to examine
  activity on Giant however.
- Expand the width of the event source names column a bit to allow for some
  of the longer names of these new source types.
2009-01-13 16:44:18 +00:00
jhb
d89e3d19c0 - Add some rudimentary support for sorting the list of event sources
(threads, CPU load counters, etc.).  Each source is tagged with a group
  and an order similar to the SYSINIT SI_SUB_* and SI_ORDER_*.  After
  the file is parsed, all the sources are then sorted.  Currently, the only
  affects of this are that the CPU loads are now sorted by CPU ID (so
  CPU 0 is always first).  However, this makes it easier to add new types
  of event sources in the future and have them all clustered together
  instead of intertwined with threads.
- Python lists perform insertions at the tail much faster than insertions
  at the head.  For a trace that had a lot of events for a single event
  source, the constant insertions of new events to the head of the
  per-source event list caused a noticable slow down.  To compensate,
  append new events to the end of the list during parsing and then
  reverse the list prior to drawing.
- Somewhere in the tkinter internals the coordinates of a canvas are
  stored in a signed 32-bit integer.  As a result, if an the box for
  an event spans 2^31, it would actually end up having a negative
  X offset at one end.  The result was a single box that covered the
  entire event source.  Kris worked around this for some traces by
  bumping up the initial ticks/pixel ratio from 1 to 10.  However, a
  divisor of 10 can still be too small for large tracefiles (e.g.
  with 4 million entries).  Instead of hardcoding the initial scaling
  ratio, calculate it from the time span of the trace file.
- Add support for using the mouse wheel to scroll the graph window
  up and down.
2009-01-13 16:33:10 +00:00
jeff
33da69dc61 - Remove cumbersome and inaccurate attempt at synchronizing the timestamps
post collection.  This is too error prone and introduces uncertainty into
   the timing.  We'll simply have to require synchronized TSCs to run
   schedgraph on MP.

Sponsored by:	Nokia
2008-04-26 05:02:48 +00:00
jhb
e2e2970333 Update the timestamp regexps in syncstamp() and monostamp() for > 99999
traces where there isn't any leading whitespace before the record number
in the ktrdump output.
2008-01-25 19:24:12 +00:00
kris
4c2abb46e1 * Remove KTR_CPUMASK, it is not correct to set this
* Explain why 32768 entries is usually not enough

* Increase the scaling ratio to 10 to deal with 32-bit overflows that
  can occur in calculating the canvas offsets
2008-01-13 22:46:24 +00:00
sam
6ea4f452e3 o expand usage comments; add cut&paste items for bozo's like me
o add things i want to TODO list
o add Record entry to each event which back-maps to the line # in the ktr file;
  useful for finding local context when the ktr file has lots of items that
  schedgraph doesn't grok
o add missing KTR_SCHED event handlers
o expose Counter max value through a ymax method for widget building
o show timestamps in records rejected 'cuz time goes backwards
2007-11-19 04:46:37 +00:00
jeff
0923616b22 - Fix the ktr header regexp so we match lines with very large indexes.
- Add support for messages where cpu load is added to a remote cpu.
 - print unmatched lines to stdout
2007-11-12 17:33:07 +00:00
kris
fe3371c666 Add some notes clarifying usage and a couple of known bugs 2007-04-22 06:20:12 +00:00
jeff
04228656e7 - Add a horrible bit of code to detect tsc differences between processors.
This only works if there is no significant drift and all processors are
   running at the same frequency.  Fortunately, schedgraph traces on MP
   machines tend to cover less than a second so drift shouldn't be an issue.
 - KTRFile::synchstamp() iterates once over the whole list to determine the
   lowest tsc value and syncs adjusts all other values to match.  We assume
   that the first tick recorded on all cpus happened at the same instant to
   start with.
 - KTRFile::monostamp() iterates again over the whole file and checks for
   a cpu agnostic monotonically increasing clock.  If the time ever goes
   backwards the cpu responsible is adjusted further to fit.  This will
   make the possible incorrect delta between cpus as small as the shortest
   time between two events.  This time can be fairly large due to sched_lock
   essentially protecting all events.
 - KTRFile::checkstamp() now returns an adjusted timestamp.
 - StateEvent::draw() detects states that occur out of order in time and
   draws them as 0 pixels after printing a warning.
2007-01-24 21:19:56 +00:00
jeff
9ea1e03533 - Print clock information so we know if something is not reported correctly
from the tsc.
 - Set skipnext = 1 for yielding and preempted events so we don't show the
   event that adds us back to the run queue.  It used to be 2 so we would
   skip the ksegrp run queue addition and the system run queue addition
   but the ksegrp run queue has gone away.
 - Don't display down to nanosecond resolution for scheduling events right
   now.  This can sometimes cause a division by zero.
2007-01-23 22:19:27 +00:00
jeff
c164b22f4a - Add colors for up to 8 cpus. 2007-01-06 04:40:44 +00:00
scottl
01fb37711b Teach schedgraph how to parse KTR_CRITICAL records. critical_enter/exit
events are now plotted as a counting graph, similar to CPU load, so that
their duration and critnest values can be visualized.
2005-11-21 21:27:40 +00:00
rwatson
192c946ba5 Fix two minor typos that caused schedgraph to exit with an exception
when running on traces referencing >2 CPUs.
2005-11-06 17:43:25 +00:00
jeff
dfd3ed6e5d - ktrace(1) has nothing to do with schedgraph. Remove that from the
instructions.
2005-03-14 11:52:24 +00:00
arr
8de6777f0a - Add some notes on what is required to run schedgraph.py successfully.
This was pulled from Jeff Roberson's email to current@ "the other day."

Approved by: jeff@
2004-12-28 00:49:02 +00:00
jeff
7b0ff93d2d - For preemption and yield events, we want to skip the next two state events
as they are the setrunqueue() and sched_add() calls.  Since they happen
   immediately before the thread is placed on a run queue they would normally
   dwarf the more informative preemption or yield event and it is implicitly
   understood that a thread is back on the run queue as part of these events.
2004-12-26 03:25:08 +00:00
jeff
8d13141666 - Call self.checkstamp() in the cpu load parsing functions in case the
timestamp has wrapped.
2004-12-26 02:02:34 +00:00
jeff
d74da89b42 - The regexp for the load should have been (/d+), fix this so loads over 9
are properly represented.
2004-12-26 01:18:49 +00:00
jeff
02bd7382cc - Add 'schedgraph' a scheduler trace visualization tool written with
python and tkinter.  Schedgraph takes input from files produces by
   ktrdump -ct when KTR_SCHED is compiled into the kernel.  The output
   represents the states of each thread with colored line segments as well
   as colored points for non-state scheduler events.  Each line segment and
   point is clickable to obtain extra detail.
2004-12-26 00:13:07 +00:00