6 The vppinfra event logger provides very lightweight (sub-100ns)
7 precisely time-stamped event-logging services. See
8 ./src/vppinfra/{elog.c, elog.h}
10 Serialization support makes it easy to save and ultimately to combine a
11 set of event logs. In a distributed system running NTP over a local LAN,
12 we find that event logs collected from multiple system elements can be
13 combined with a temporal uncertainty no worse than 50us.
15 A typical event definition and logging call looks like this:
19 ELOG_TYPE_DECLARE (e) =
21 .format = "tx-msg: stream %d local seq %d attempt %d",
22 .format_args = "i4i4i4",
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;
30 The ELOG\_DATA macro returns a pointer to 20 bytes worth of arbitrary
31 event data, to be formatted (offline, not at runtime) as described by
32 format\_args. Aside from obvious integer formats, the CLIB event logger
33 provides a couple of interesting additions. The "t4" format
34 pretty-prints enumerated values:
38 ELOG_TYPE_DECLARE (e) =
40 .format = "get_or_create: %s",
43 .enum_strings = { "old", "new", },
46 The "t" format specifier indicates that the corresponding datum is an
47 index in the event's set of enumerated strings, as shown in the previous
48 event type definition.
50 The “T” format specifier indicates that the corresponding datum is an
51 index in the event log’s string heap. This allows the programmer to emit
52 arbitrary formatted strings. One often combines this facility with a
53 hash table to keep the event-log string heap from growing arbitrarily
56 Noting the 20-octet limit per-log-entry data field, the event log
57 formatter supports arbitrary combinations of these data types. As in:
58 the ".format" field may contain one or more instances of the following:
60 - i1 - 8-bit unsigned integer
61 - i2 - 16-bit unsigned integer
62 - i4 - 32-bit unsigned integer
63 - i8 - 64-bit unsigned integer
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
71 The vpp engine event log is thread-safe, and is shared by all threads.
72 Take care not to serialize the computation. Although the event-logger is
73 about as fast as practicable, it's not appropriate for per-packet use in
74 hard-core data plane code. It's most appropriate for capturing rare
75 events - link up-down events, specific control-plane events and so
78 The vpp engine has several debug CLI commands for manipulating its event
81 .. code-block:: console
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
89 The event log defaults to 128K entries. The command-line argument "...
90 vlib { elog-events nnn } ..." configures the size of the event log.
92 As described above, the vpp engine event log is thread-safe and shared.
93 To avoid confusing non-appearance of events logged by worker threads,
94 make sure to code vlib\_global\_main.elog\_main - instead of
95 vm->elog\_main. The latter form is correct in the main thread, but
96 will almost certainly produce bad results in worker threads.
98 G2 graphical event viewer
99 ==========================
101 The G2 graphical event viewer can display serialized vppinfra event logs
102 directly, or via the c2cpel tool. G2 is a fine-grained event-log viewer. It's
103 highly scalable, supporting O(1e7 events) and O(1e3 discrete display "tracks").
104 G2 displays binary data generated by the vppinfra "elog.[ch]" logger component,
105 and also supports the CPEL file format, as described in this section.
110 .. code-block:: console
114 $ ./install-native/g2/bin/g2 --help
115 g2 [--ticks-per-us <value>][--cpel-input <filename>] [--clib-input <filename]>
116 G2 (x86_64 GNU/Linux) major version 3.0
117 Built Wed Feb 3 10:58:12 EST 2016
119 Setting the Display Preferences
120 ------------------------------------------------
122 The file $<*HOMEDIR*>/.g2 contains display preferences, which can be overridden.
123 Simply un-comment one of the stanzas shown below, or experiment as desired.
128 * Property / parameter settings for G2
130 * Setting for a 1024x768 display:
131 * event_selector_lines=20
135 * new mac w/ no monitor:
136 * event_selector_lines=20
137 * drawbox_height=1200
142 * drawbox_height=1000
143 * event_selector_lines=25
145 * for making screenshots on a Macbook Pro
148 * event_selector_lines=20
152 ----------------------------
154 Here is an annotated G2 viewer screenshot, corresponding to activity during BGP
155 prefix download. This data was captured on a Cisco IOS-XR system:
157 .. figure:: /_images/g21.jpg
161 The viewer has two main scrollbars: the horizontal axis scrollbar shifts the main
162 drawing area in time; the vertical axis changes the set of visible process traces.
163 The zoomin / zoomout operators change the time scale.
165 The event selector PolyCheckMenu changes the set of displayed events.
166 Using these tools -- and some patience -- you can understand a given event log.
169 -------------------------
171 G2 has three fairly sophisticated mouse gesture interfaces, which are worth describing
172 in detail. First, a left mouse click on a display event pops up a per-event detail box.
174 .. figure:: /_images/g22.jpg
177 A left mouse click on an event detail box closes it.
178 To zoom to a region of the display, press and hold the left mouse button, then drag
179 right or left until the zoom-fence pair appears:
181 .. figure:: /_images/g23.jpg
184 When the zoom operation completes, the display is as follows:
186 .. figure:: /_images/g24.jpg
188 A click on any of the figures will show them at full resolution, right-click will open figures in new tabs,
193 To use a time ruler, press and hold the right mouse button; drag right or left
194 until the ruler measures the region of interest. If the time axis scale is coarse,
195 event boxes can have significant width in time, so use a "reference point" in
196 each event box when using the time ruler.
198 .. figure:: /_images/g25.jpg
202 -------------------------
204 Changing the Event Selector setup controls the set of points displayed in an
205 obvious way. Here, we suppress all events except "this thread is now running on the CPU":
207 .. figure:: /_images/g26.jpg
210 Same setup, with all events displayed:
212 .. figure:: /_images/g27.jpg
215 Note that event detail boxes previously shown, but suppressed due to deselection
216 of the event code will reappear when one reselects the event code. In the example
217 above, the "THREAD/THREADY pid:491720 tid:12" detail box appears in this fashion.
220 -----------------------
222 Three buttons in lower left-hand corner of the g2 main window control the snapshot
223 ring. Snapshots are simply saved views: maneuver the viewer into an "interesting"
224 configuration, then press the "Snap" button to add a snapshot to the ring.
226 Click **Next** to restore the next available snapshot. The **Del** button deletes the current snapshot.
228 See the hotkey section below for access to a quick and easy method to save and
229 restore the snapshot ring. Eventually we may add a safe/portable/supported mechanism
230 to save/restore the snapshot ring from CPEL and vppinfra event log files.
233 ------------------------
235 Event chasing sorts the trace axis by occurrence of the last selected event. For
236 example, if one selects an event which means "thread running on the CPU" the first
237 N displayed traces will be the first M threads to run (N <= M; a thread may run
238 more than once. This feature addresses analytic problems caused by the finite size of the drawing area.
240 In standard (NoChaseEvent) mode, it looks like only BGP threads 5 and 9 are active:
242 .. figure:: /_images/g28.jpg
245 After pressing the ChaseEvent button, we see a different picture:
247 .. figure:: /_images/g29.jpg
250 Burying Boring Tracks
251 -----------------------------------
253 The sequence <ctrl><left-mouse-click> moves the track under the mouse to the end
254 of the set of tracks, effectively burying it. The sequence <shift><left-mouse-click>
255 moves the track under the mouse to the beginning of the set of tracks. The latter
256 function probably isn't precisely right--I think we may eventually provide an "undo"
257 stack to provide precise thread exhumation.
260 -------------------------
262 Summary mode declutters the screen by rendering events as short vertical line
263 segments instead of numbered boxes. Event detail display is unaffected. G2 starts
264 in summary mode, zoomed out sufficiently for all events in the trace to be displayed.
265 Given a large number of events, summary mode reduces initial screen-paint time to a
266 tolerable value. Once you've zoomed in sufficiently, type "e" - enter event mode,
267 to enable boxed numeric event display.
272 G2 supports the following hotkey actions, supposedly (circa 1996) Quake-like
273 according to the feature's original author:
275 +----------------------+--------------------------------------------------------+
277 +======================+========================================================+
279 +----------------------+--------------------------------------------------------+
281 +----------------------+--------------------------------------------------------+
283 +----------------------+--------------------------------------------------------+
285 +----------------------+--------------------------------------------------------+
286 | e | Toggle between event and summary-event mode |
287 +----------------------+--------------------------------------------------------+
288 | p | Put (write) snapshot ring to snapshots.g2 |
289 +----------------------+--------------------------------------------------------+
290 | l | Load (read) snapshot ring from snapshots.g2 |
291 +----------------------+--------------------------------------------------------+
293 +----------------------+--------------------------------------------------------+