lib: remove stream activity messages
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 20 Jun 2019 21:14:46 +0000 (17:14 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 8 Jul 2019 17:10:09 +0000 (13:10 -0400)
commit188edac1113dbbb29030681dbde2de0ada742499
tree527c840259754b647bfbb68aa2ec2d53d4fccf26
parent1fba7c7b9ff8f36fde916dfb2317855549f0eb5b
lib: remove stream activity messages

The stream activity messages were introduced to support eventual use
cases where the tracer could indicate when it stopped tracing and
started again.  To this day, no tracer which produces CTF provides this
information, so these messages are not currently useful.  Stream
activity beginning messages are only ever sent just after stream
beginning, and stream activity end messages are only ever sent just
before stream end.

Given that we will introduce a versioning system for the inter-component
communication protocol, which will allow adding new features, we can
remove the stream activity messages for now and add them at a latter
time, if need be.  This will reduce a little bit the amount of
boilerplate needed to implement a simple source.

So this patch removes the stream activity messages and handles all the
fallout.

One thing is that the stream activity messages optionally carried a
default clock snapshot, which is used by the trimmer component.  To
compensate for this loss of feature, the stream beginning/end messages
now have an optional default clock snapshot.

Impacts around the codebase include (on top of simply removing handling
of stream activity messages):

- sink.text.details: Update to include the default clock snapshot for
  stream beginning/end.
- flt.utils.trimmer: read clock snapshots from stream beginning/end
  messages (if not unknown).  These messages can now trigger the end of
  the trimming, if their default clock snapshot is greater than the end
  time of the trimmer.  Set the clock snapshot of the generated stream
  end message if the stream is ended by the trimmer's end bound (see
  note below for more details).  If the stream is ended because of a
  stream end message that is within the trimmer's bounds, the stream
  end message is not modified.
- iterator: handle stream message clock snapshots when validating clock
  monotonicity and doing an auto seek.

Note about clock snapshot handling
----------------------------------

This patch fixes a bug in trimmer's handle_message_with_stream function,
where it currently always returns BT_SELF_MESSAGE_ITERATOR_STATUS_OK,
even when something fails.  Changing it to return the "status" variable
(as I suppose the original intention was) uncovers a latent bug with
the clock snapshots of the "stream end" messages we
generate (or for stream activity end messages, before this patch).

Imagine a clock with a frequency of 1 and offset of 1000s.  This means
that the raw clock value 0 corresponds to the real time 1000s, 50 is
1050, and so on.  This clock is unable to represent real times prior to
1000s.  The sequence of messages generated by the source is:

1. Stream beginning, no clock snapshot
2. Packet beginning at 1050s (raw value 50)

Here's what happens in the trimmer's mind if we pass --end=200:

- Receive message 1, record that a stream is open
- Receive message 2, realize its clock snapshot is greater than the end
  bound.  Drop it and end the streams.
- Generate a stream end message, use own end bound (200s) as the clock
  snapshot
- Try to convert 200s to a raw value of the clock described above: it
  fails because 200s can't be represented by that clock.

This is fixed by recording whether we have seen a message with a valid
clock snapshot associated with the stream (which can therefore be
represented by the stream's class' clock class).  If we have, it means
that the clock snapshot we'll choose for the stream end message we'll
generate will be safe to convert to a clock value of that clock class.
If we haven't, we are not sure.

A similar problem happens in the iterator auto-seek code when using
'--begin=200' and the same setup as above.  We'll try to generate a
stream beginning message with clock snapshot 200s, which is invalid.

Note that this approach could be problematic in some corner cases,
here's a known one:

Once trimmer supports packet beginning/end messages without clock
snapshots (remember that whether these messages have a clock
snapshot or not is dictated by the stream class, it's not a choice per
message), this could happen:

- stream class defines that packet beginning messages don't have clock
snapshots, but packet end messages do.
- get stream beginning message without clock snapshot
- get packet beginning message without clock snapshot
- get event message with clock snapshot, greater than the end bound of
  200s
- since the stream class defines that packet end messages must have a
  clock snapshot, we can't get away by not putting one as is done by
  this patch.

A more complex solution along these lines would probably be needed:

- When trimmer receives the stream and packet beginning messages without
  clock snapshot, don't send them downstream but take a note of the
  state of the stream
- When we do get a first message with a clock snapshot, then send the
  required stream and packet beginning messages.
- If the trimming ends without having sent any content in this
  stream/packet, just pretend it never existed.

Change-Id: I9a30a4c33b3f94497254ef93b24fed3b463e13fa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1527
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
50 files changed:
configure.ac
include/Makefile.am
include/babeltrace2/babeltrace.h
include/babeltrace2/graph/message-const.h
include/babeltrace2/graph/message-stream-activity-beginning-const.h [deleted file]
include/babeltrace2/graph/message-stream-activity-beginning.h [deleted file]
include/babeltrace2/graph/message-stream-activity-const.h [deleted file]
include/babeltrace2/graph/message-stream-activity-end-const.h [deleted file]
include/babeltrace2/graph/message-stream-activity-end.h [deleted file]
include/babeltrace2/graph/message-stream-beginning-const.h
include/babeltrace2/graph/message-stream-beginning.h
include/babeltrace2/graph/message-stream-const.h [new file with mode: 0644]
include/babeltrace2/graph/message-stream-end-const.h
include/babeltrace2/graph/message-stream-end.h
src/bindings/python/bt2/bt2/__init__.py.in
src/bindings/python/bt2/bt2/clock_snapshot.py
src/bindings/python/bt2/bt2/message.py
src/bindings/python/bt2/bt2/message_iterator.py
src/bindings/python/bt2/bt2/native_bt_message.i
src/lib/graph/iterator.c
src/lib/graph/message/Makefile.am
src/lib/graph/message/message.h
src/lib/graph/message/stream-activity.c [deleted file]
src/lib/graph/message/stream-activity.h [deleted file]
src/lib/graph/message/stream.c
src/lib/graph/message/stream.h
src/lib/lib-logging.c
src/plugins/ctf/common/msg-iter/msg-iter.c
src/plugins/ctf/fs-sink/fs-sink.c
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/lttng-utils/debug-info/debug-info.c
src/plugins/text/details/write.c
src/plugins/text/dmesg/dmesg.c
src/plugins/utils/counter/counter.c
src/plugins/utils/counter/counter.h
src/plugins/utils/muxer/muxer.c
src/plugins/utils/trimmer/trimmer.c
tests/Makefile.am
tests/bindings/python/bt2/test_message.py
tests/bindings/python/bt2/test_message_iterator.py
tests/bindings/python/bt2/test_trace_collection_message_iterator.py
tests/data/plugins/flt.utils.trimmer/bt_plugin_trimmer_test.py [new file with mode: 0644]
tests/data/plugins/sink.ctf.fs/succeed/trace-double.expect
tests/data/plugins/sink.ctf.fs/succeed/trace-float.expect
tests/data/plugins/src.ctf.fs/succeed/trace-simple.expect
tests/data/plugins/src.ctf.fs/succeed/trace-smalltrace.expect
tests/plugins/Makefile.am
tests/plugins/flt.utils.trimmer/Makefile.am [new file with mode: 0644]
tests/plugins/flt.utils.trimmer/test_trimming [new file with mode: 0755]
tests/plugins/flt.utils.trimmer/test_trimming_wrapper [new file with mode: 0755]
This page took 0.030022 seconds and 4 git commands to generate.