blob: 21d5fa95275d404338a3f0cdd3ec5dc3a0fc1ec2 [file] [log] [blame]
John DeNisco2ba9dcf2018-08-23 14:04:22 -04001.. _eventviewer:
2
3Event-logger
4============
5
6The vppinfra event logger provides very lightweight (sub-100ns)
7precisely time-stamped event-logging services. See
8./src/vppinfra/{elog.c, elog.h}
9
10Serialization support makes it easy to save and ultimately to combine a
11set of event logs. In a distributed system running NTP over a local LAN,
12we find that event logs collected from multiple system elements can be
13combined with a temporal uncertainty no worse than 50us.
14
15A typical event definition and logging call looks like this:
16
17.. code-block:: c
18
Dave Barach3fef8f82019-03-15 11:27:30 -040019 ELOG_TYPE_DECLARE (e) =
John DeNisco2ba9dcf2018-08-23 14:04:22 -040020 {
21 .format = "tx-msg: stream %d local seq %d attempt %d",
22 .format_args = "i4i4i4",
23 };
24 struct { u32 stream_id, local_sequence, retry_count; } * ed;
25 ed = ELOG_DATA (m->elog_main, e);
26 ed->stream_id = stream_id;
27 ed->local_sequence = local_sequence;
28 ed->retry_count = retry_count;
29
30The ELOG\_DATA macro returns a pointer to 20 bytes worth of arbitrary
31event data, to be formatted (offline, not at runtime) as described by
32format\_args. Aside from obvious integer formats, the CLIB event logger
33provides a couple of interesting additions. The "t4" format
34pretty-prints enumerated values:
35
36.. code-block:: c
37
Dave Barach3fef8f82019-03-15 11:27:30 -040038 ELOG_TYPE_DECLARE (e) =
John DeNisco2ba9dcf2018-08-23 14:04:22 -040039 {
40 .format = "get_or_create: %s",
41 .format_args = "t4",
42 .n_enum_strings = 2,
43 .enum_strings = { "old", "new", },
44 };
45
46The "t" format specifier indicates that the corresponding datum is an
47index in the event's set of enumerated strings, as shown in the previous
48event type definition.
49
50The “T” format specifier indicates that the corresponding datum is an
51index in the event log’s string heap. This allows the programmer to emit
52arbitrary formatted strings. One often combines this facility with a
53hash table to keep the event-log string heap from growing arbitrarily
54large.
55
56Noting the 20-octet limit per-log-entry data field, the event log
57formatter supports arbitrary combinations of these data types. As in:
58the ".format" field may contain one or more instances of the following:
59
60- i1 - 8-bit unsigned integer
61- i2 - 16-bit unsigned integer
62- i4 - 32-bit unsigned integer
63- i8 - 64-bit unsigned integer
64- f4 - float
65- f8 - double
66- s - NULL-terminated string - be careful
67- sN - N-byte character array
68- t1,2,4 - per-event enumeration ID
69- T4 - Event-log string table offset
70
71The vpp engine event log is thread-safe, and is shared by all threads.
72Take care not to serialize the computation. Although the event-logger is
73about as fast as practicable, it's not appropriate for per-packet use in
74hard-core data plane code. It's most appropriate for capturing rare
75events - link up-down events, specific control-plane events and so
76forth.
77
78The vpp engine has several debug CLI commands for manipulating its event
79log:
80
81.. code-block:: console
82
83 vpp# event-logger clear
84 vpp# event-logger save <filename> # for security, writes into /tmp/<filename>.
85 # <filename> must not contain '.' or '/' characters
86 vpp# show event-logger [all] [<nnn>] # display the event log
87 # by default, the last 250 entries
88
89The event log defaults to 128K entries. The command-line argument "...
90vlib { elog-events nnn } ..." configures the size of the event log.
91
92As described above, the vpp engine event log is thread-safe and shared.
93To avoid confusing non-appearance of events logged by worker threads,
94make sure to code vlib\_global\_main.elog\_main - instead of
95vm->elog\_main. The latter form is correct in the main thread, but
96will almost certainly produce bad results in worker threads.
97
98G2 graphical event viewer
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020099-------------------------
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400100
101The G2 graphical event viewer can display serialized vppinfra event logs
102directly, or via the c2cpel tool. G2 is a fine-grained event-log viewer. It's
103highly scalable, supporting O(1e7 events) and O(1e3 discrete display "tracks").
104G2 displays binary data generated by the vppinfra "elog.[ch]" logger component,
105and also supports the CPEL file format, as described in this section.
106
Dave Barach3fef8f82019-03-15 11:27:30 -0400107Building G2
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200108~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400109
Dave Barach3fef8f82019-03-15 11:27:30 -0400110This link describes :ref:`how to build G2 <building-g2>`
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400111
112Setting the Display Preferences
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200113~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400114
115The file $<*HOMEDIR*>/.g2 contains display preferences, which can be overridden.
116Simply un-comment one of the stanzas shown below, or experiment as desired.
117
118.. code-block:: c
119
120 /*
121 * Property / parameter settings for G2
122 *
123 * Setting for a 1024x768 display:
124 * event_selector_lines=20
125 * drawbox_height=800
126 * drawbox_width=600
Dave Barach3fef8f82019-03-15 11:27:30 -0400127 *
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400128 * new mac w/ no monitor:
129 * event_selector_lines=20
130 * drawbox_height=1200
131 * drawbox_width=700
132 *
133 * 1600x1200:
134 * drawbox_width=1200
135 * drawbox_height=1000
136 * event_selector_lines=25
Dave Barach3fef8f82019-03-15 11:27:30 -0400137 *
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400138 * for making screenshots on a Macbook Pro
139 * drawbox_width=1200
140 * drawbox_height=600
141 * event_selector_lines=20
142 */
143
144Screen Taxonomy
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200145~~~~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400146
147Here is an annotated G2 viewer screenshot, corresponding to activity during BGP
Dave Barach3fef8f82019-03-15 11:27:30 -0400148prefix download. This data was captured on a Cisco IOS-XR system:
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400149
150.. figure:: /_images/g21.jpg
151 :scale: 75%
Dave Barach3fef8f82019-03-15 11:27:30 -0400152
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400153
154The viewer has two main scrollbars: the horizontal axis scrollbar shifts the main
155drawing area in time; the vertical axis changes the set of visible process traces.
156The zoomin / zoomout operators change the time scale.
157
Dave Barach3fef8f82019-03-15 11:27:30 -0400158The event selector PolyCheckMenu changes the set of displayed events.
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400159Using these tools -- and some patience -- you can understand a given event log.
160
161Mouse Gestures
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200162~~~~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400163
164G2 has three fairly sophisticated mouse gesture interfaces, which are worth describing
Dave Barach3fef8f82019-03-15 11:27:30 -0400165in detail. First, a left mouse click on a display event pops up a per-event detail box.
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400166
167.. figure:: /_images/g22.jpg
168 :scale: 75%
169
Dave Barach3fef8f82019-03-15 11:27:30 -0400170A left mouse click on an event detail box closes it.
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400171To zoom to a region of the display, press and hold the left mouse button, then drag
172right or left until the zoom-fence pair appears:
173
174.. figure:: /_images/g23.jpg
175 :scale: 75%
176
Dave Barach3fef8f82019-03-15 11:27:30 -0400177When the zoom operation completes, the display is as follows:
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400178
179.. figure:: /_images/g24.jpg
180
181A click on any of the figures will show them at full resolution, right-click will open figures in new tabs,
182
183Time Ruler
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200184~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400185
186To use a time ruler, press and hold the right mouse button; drag right or left
187until the ruler measures the region of interest. If the time axis scale is coarse,
188event boxes can have significant width in time, so use a "reference point" in
Dave Barach3fef8f82019-03-15 11:27:30 -0400189each event box when using the time ruler.
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400190
191.. figure:: /_images/g25.jpg
192 :scale: 75%
193
194Event Selection
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200195~~~~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400196
197Changing the Event Selector setup controls the set of points displayed in an
Dave Barach3fef8f82019-03-15 11:27:30 -0400198obvious way. Here, we suppress all events except "this thread is now running on the CPU":
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400199
200.. figure:: /_images/g26.jpg
201 :scale: 75%
202
Dave Barach3fef8f82019-03-15 11:27:30 -0400203Same setup, with all events displayed:
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400204
205.. figure:: /_images/g27.jpg
206 :scale: 75%
207
208Note that event detail boxes previously shown, but suppressed due to deselection
209of the event code will reappear when one reselects the event code. In the example
210above, the "THREAD/THREADY pid:491720 tid:12" detail box appears in this fashion.
211
212Snapshot Ring
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200213~~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400214
215Three buttons in lower left-hand corner of the g2 main window control the snapshot
216ring. Snapshots are simply saved views: maneuver the viewer into an "interesting"
217configuration, then press the "Snap" button to add a snapshot to the ring.
218
219Click **Next** to restore the next available snapshot. The **Del** button deletes the current snapshot.
220
221See the hotkey section below for access to a quick and easy method to save and
222restore the snapshot ring. Eventually we may add a safe/portable/supported mechanism
223to save/restore the snapshot ring from CPEL and vppinfra event log files.
224
225Chasing Events
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200226~~~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400227
228Event chasing sorts the trace axis by occurrence of the last selected event. For
229example, if one selects an event which means "thread running on the CPU" the first
230N displayed traces will be the first M threads to run (N <= M; a thread may run
231more than once. This feature addresses analytic problems caused by the finite size of the drawing area.
232
Dave Barach3fef8f82019-03-15 11:27:30 -0400233In standard (NoChaseEvent) mode, it looks like only BGP threads 5 and 9 are active:
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400234
235.. figure:: /_images/g28.jpg
236 :scale: 75%
237
Dave Barach3fef8f82019-03-15 11:27:30 -0400238After pressing the ChaseEvent button, we see a different picture:
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400239
240.. figure:: /_images/g29.jpg
241 :scale: 75%
242
243Burying Boring Tracks
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200244~~~~~~~~~~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400245
246The sequence <ctrl><left-mouse-click> moves the track under the mouse to the end
247of the set of tracks, effectively burying it. The sequence <shift><left-mouse-click>
248moves the track under the mouse to the beginning of the set of tracks. The latter
249function probably isn't precisely right--I think we may eventually provide an "undo"
250stack to provide precise thread exhumation.
251
252Summary Mode
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200253~~~~~~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400254
255Summary mode declutters the screen by rendering events as short vertical line
256segments instead of numbered boxes. Event detail display is unaffected. G2 starts
257in summary mode, zoomed out sufficiently for all events in the trace to be displayed.
258Given a large number of events, summary mode reduces initial screen-paint time to a
259tolerable value. Once you've zoomed in sufficiently, type "e" - enter event mode,
260to enable boxed numeric event display.
261
262Hotkeys
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200263~~~~~~~
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400264
265G2 supports the following hotkey actions, supposedly (circa 1996) Quake-like
Dave Barach3fef8f82019-03-15 11:27:30 -0400266according to the feature's original author:
John DeNisco2ba9dcf2018-08-23 14:04:22 -0400267
268+----------------------+--------------------------------------------------------+
269| Key | Function |
270+======================+========================================================+
271| w | Zoom-in |
272+----------------------+--------------------------------------------------------+
273| s | Zoom-out |
274+----------------------+--------------------------------------------------------+
275| a | Scroll Left |
276+----------------------+--------------------------------------------------------+
277| d | Scroll Right |
278+----------------------+--------------------------------------------------------+
279| e | Toggle between event and summary-event mode |
280+----------------------+--------------------------------------------------------+
281| p | Put (write) snapshot ring to snapshots.g2 |
282+----------------------+--------------------------------------------------------+
283| l | Load (read) snapshot ring from snapshots.g2 |
284+----------------------+--------------------------------------------------------+
285| <ctrl>-q | quit |
286+----------------------+--------------------------------------------------------+