Fix: CTF and Babeltrace links
[lttng-docs.git] / contents / using-lttng / controlling-tracing / enabling-disabling-channels / fine-tuning-channels.md
CommitLineData
5e0cbfb0
PP
1---
2id: fine-tuning-channels
3---
4
5There are various parameters that may be fine-tuned with the
6`enable-channel` command. The latter are well documented in
5037eb52 7<a href="/man/1/lttng" class="ext">the man page of `lttng`</a>
5e0cbfb0
PP
8and in the [Channel](#doc-channel) section of the
9[Understanding LTTng](#doc-understanding-lttng) chapter. For basic
10tracing needs, their default values should be just fine, but here are a
11few examples to break the ice.
12
13As the frequency of recorded events increases&mdash;either because the
14event throughput is actually higher or because you enabled more events
15than usual&mdash;_event loss_ might be experienced. Since LTTng never
16waits, by design, for sub-buffer space availability (non-blocking
17tracer), when a sub-buffer is full and no empty sub-buffers are left,
18there are two possible outcomes: either the new events that do not fit
19are rejected, or they start replacing the oldest recorded events.
20The choice of which algorithm to use is a per-channel parameter, the
21default being discarding the newest events until there is some space
22left. If your situation always needs the latest events at the expense
23of writing over the oldest ones, create a channel with the `--overwrite`
24option:
25
26<pre class="term">
27lttng enable-channel --kernel --overwrite my-channel
28</pre>
29
30When an event is lost, it means no space was available in any
31sub-buffer to accommodate it. Thus, if you want to cope with sporadic
32high event throughput situations and avoid losing events, you need to
33allocate more room for storing them in memory. This can be done by
34either increasing the size of sub-buffers or by adding sub-buffers.
35The following example creates a user space domain channel with
3616&nbsp;sub-buffers of 512&nbsp;kiB each:
37
38<pre class="term">
39lttng enable-channel --userspace --num-subbuf 16 --subbuf-size 512k big-channel
40</pre>
41
42Both values need to be powers of two, otherwise they are rounded up
43to the next one.
44
45Two other interesting available parameters of `enable-channel` are
46`--tracefile-size` and `--tracefile-count`, which respectively limit
47the size of each trace file and the their count for a given channel.
48When the number of written trace files reaches its limit for a given
47bfcb75 49channel-CPU pair, the next trace file overwrites the very first
5e0cbfb0
PP
50one. The following example creates a kernel domain channel with a
51maximum of three trace files of 1&nbsp;MiB each:
52
53<pre class="term">
54lttng enable-channel --kernel --tracefile-size 1M --tracefile-count 3 my-channel
55</pre>
56
57An efficient way to make sure lots of events are generated is enabling
58all kernel events in this channel and starting the tracer:
59
60<pre class="term">
61lttng enable-event --kernel --all --channel my-channel
62lttng start
63</pre>
64
65After a few seconds, look at trace files in your tracing session
66output directory. For two CPUs, it should look like:
67
68~~~ text
69my-channel_0_0 my-channel_1_0
70my-channel_0_1 my-channel_1_1
71my-channel_0_2 my-channel_1_2
72~~~
73
74Amongst the files above, you might see one in each group with a size
75lower than 1&nbsp;MiB: they are the files currently being written.
76
77Since all those small files are valid LTTng trace files, LTTng trace
78viewers may read them. It is the viewer's responsibility to properly
79merge the streams so as to present an ordered list to the user.
1bf7ee86 80<a href="http://diamon.org/babeltrace" class="ext">Babeltrace</a>
5e0cbfb0 81merges LTTng trace files correctly and is fast at doing it.
This page took 0.026094 seconds and 4 git commands to generate.