consumerd: send a buffer static sample on flush command
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 21 Jun 2022 20:56:23 +0000 (16:56 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 4 Jul 2022 15:43:43 +0000 (11:43 -0400)
commit9cc4ae91845c03b141af7ef58a86a2a9689dfafd
tree7ddb502c48b73a8b0915bdded3f1cd8c641bc48b
parentc715ddc950bf653d9456d92c6ead2e3cbd3c54ae
consumerd: send a buffer static sample on flush command

When application exits during per-pid tracing, both the session and
consumer daemons notice it. The session daemon sees the application's
command pipe hanging-up, while the consumer daemon sees the
application's data-ready pipe hanging-up.

Upon handling this event, both daemons tear down their representation of
the channels.

In an ideal world, we'd want to sample the streams' "consumed_size" at the
last possible moment to get the size of all consumed data for this
stream. However, this is problematic in the following scenario:
  - the sessiond destroys the channel before the consumer daemon,
  - the consumer daemon sends a final buffer stats sample on tear down,
  - the sessiond can do nothing with the sample as it doesn't know that
    channel anymore.

Note that the session daemon handles the case where it doesn't know a
channel gracefully.

When an application being traced in per-pid mode is torn down, the
session requests a flush of its buffers to the consumer daemon. We can
use this opportunity to emit a buffer stats sample.

This is still racy since the tear down of the channel could complete on
the session daemon's end before that last sample can be processed. In
practice, though, it markedly improves the precision of size-based
rotations in per-pid tracing mode.

On my work machine, I see the size-based rotation tests pass with
archive sizes within ~10% of the size threshold. Before this, we lost a
lot of samples from short-lived buffers and it would not be rare to see
archives end-up multiple times (5x-10x) larger than the size-threshold.

Another problem is that the consumed_size returned by the consumer
daemon will not include the packets that have yet to be consumed.

Whether or not this is a fix is debatable since it arguably just
improves the precision of size-based rotations.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8a72328ba1733ac2f50c77a1ff81d7a6aaac095c
src/common/consumer/consumer-timer.cpp
src/common/consumer/consumer.hpp
src/common/ust-consumer/ust-consumer.cpp
This page took 0.02481 seconds and 4 git commands to generate.