Event log¶
The event log stores information about each non-deterministic event that affects the execution of the program. These events include:
Reads from shared memory.
Asynchronous signal delivery.
Thread switches and thread interactions.
Non-deterministic machine instructions.
Event log rotation¶
In the default (circular) mode, the Undo Engine discards events from the beginning of the event log in order to make space for new events. This means that the program can continue to run without allocating extra space for the event log.
Note
When an event is discarded from the event log, the execution history prior to the event can no longer be replayed.
Note
When UDB is loading a recording, this setting is ignored and the complete event log is loaded.
Configuring event log size¶
Memory is allocated dynamically for the event log as required, and by default is
limited to 1GB on x64 and 256MB on other platforms. To query the event log size,
use the info event-log-size command. The maximum size can be configured
when starting UDB, either using the --max-event-log-size
command-line option, for example:
$ udb --max-event-log-size 2G
or using the UNDO_event_log_max
environment variable:
$ UNDO_event_log_max=2G udb
In either case specify the maximum size as a number followed by an optional
multiplier (K
for kilobytes, M
for megabytes, or G
for gigabytes),
or as 0 to choose a suitable size.
Note
It’s recommended to set the event log size to a value that is substantially smaller than the available system memory, otherwise UDB risks being killed by the Linux out-of-memory (OOM) killer.
Note
When UDB is loading a recording, this setting is ignored and the complete event log is loaded.
info event-log-size¶
Report the current size of the event log.
For example:
recording 8,304> info event-log-size The event log size is 67108864 bytes (64.00M).
set max-event-log-size size[K|M|G]¶
Set the maximum size to which the event log may grow.
For example:
recording 8,304> set max-event-log-size 1 Maximum event log size rounded up to 67108864 bytes (64.00M). recording 8,304> set max-event-log-size 512M Maximum event log size set to 536870912 bytes (512.00M). recording 8,304> set max-event-log-size 1G Maximum event log size set to 1073741824 bytes (1.00G).
show max-event-log-size¶
The maximum size of the event log.
For example:
recording 8,304> show max-event-log-size Maximum event log size is 1073741824 bytes (1.00G).
Using a straight event log¶
If you prefer the event log not be rotated, you can switch to the “straight” event log mode. In this mode, when the event log is full, UDB stops the program and emits this message:
ERROR: The Undo Engine's event log is full, so no more history can be recorded.
You may still use UDB commands to go backwards, or alternatively: Use "set
max-event-log-size <size>[K|M|G]" to increase the event log size, or use "set
event-log-mode circular" to use a circular event log. The current event log
size is 67108864 bytes (64.00M).
At this point you can increase the maximum event log size using the set max-event-log-size, or switch to a circular event log using the set event-log-mode command.
Configure the event log when starting UDB, either using the
--event-log-mode
command-line option, for
example:
$ udb --event-log-mode straight
or using the UNDO_event_log_mode
environment variable:
$ UNDO_event_log_mode=straight udb
set event-log-mode circular|straight¶
Set the event log mode.
For example:
recording 8,304> set event-log-mode straightThe default (circular) event log mode can be restored using:
recording 8,304> set event-log-mode circular
show event-log-mode¶
The event log mode (circular or straight).
For example:
recording 8,304> show event-log-mode The event log mode is circular.
Event statistics¶
When investigating a performance issue, or trying to get an understanding of where a program is spending its time, use the info event-stats to output a summary table of statistics for each type of event. For example:
recording 221,166> info event-stats
Count %Count Total size %Size Event type
(bytes)
------- -------- ------------ ------- -----------------
67 46.21 4,288 27.35 CPUID
22 15.17 1,760 11.23 write
12 8.28 1,694 10.80 mmap
8 5.52 512 3.27 RDTSC
4 2.76 960 6.12 fstat
4 2.76 512 3.27 mprotect
3 2.07 384 2.45 brk
3 2.07 240 1.53 openat
Events with names in lower case are system calls executed by the program as it was recorded, and events with names in upper case are other kinds of non-deterministic behavior. See Common event types below.
info event-stats [start[,stop]]¶
Table of event types. The optional arguments start and stop specify the range of events to summarize, and must either be bbcounts, or in the form base[[+|-]offset], where base is
b
(beginning),c
(current) ore
(end) and offset is the number of events to count from base. If stop is omitted it defaults to start + 10. If both start and stop are omitted, the range is the whole event log.The output is a table with one row for each type of event, giving the count of events of that type, their proportion of events as a percentage, their total size in bytes, their proportion of the event log size as a percentage, and the name of the event type. Event with names in lower case are system calls, and events with names in upper case are other kinds of non-deterministic behavior. The table is sorted in descending order by the count.
Common event types¶
Events with names in lower case are system calls executed by the program as it was recorded, and events with names in upper case are other kinds of non-deterministic behavior. Some common events in the latter category are described below.
CPUID
The
CPUID
(CPU identification) instruction on x32 and x64. This queries the features of the processor, and is used by library code to select implementations at runtime according to the available features, for example, the standard C library might select an implementation ofmemcpy()
using instructions in the AVX512 extension, if those instructions are available.In the example above, the program is short, so the event log is dominated by
CPUID
instructions issued by the standard C library when it was loaded.
NDETERM
This is a catch-all for any instruction that updates registers non-deterministically. Some common instructions have their own events, for example,
CPUID
andRDTSC
, but rare instructions use the genericNDETERM
event. Examples includeLSL
(load segment limit),IN
(input from port), andOUT
(output to port).
RDTSC
The
RDTSC
(read time-stamp counter) instruction on x32 and x64. This queries the processor’s time-stamp counter, which increments every clock cycle. This is used to implementclock_gettime()
with theCLOCK_PROCESS_CPUTIME_ID
argument, or more generally for high-frequency time measurement.
SHMEM_FIXUP
A non-deterministic change to shared memory. The program read the contents of a region of shared memory and it was found that the contents had changed since the last time the memory was in a known state. This means that another process changed the memory (if the region is mapped anonymously), or that the mapped file changed in the file system (if the region is mapped from a file).
SIG_TOCHILD
A signal was received by the program being recorded.
STATUS_TODEBUGGER
A signal was received by the debugger.
THREADSWITCH
The program switched threads. (The Undo Engine serializes the execution of threads, so that one thread executes at a time and the Engine switches between them.)