Commit Graph

91 Commits

Author SHA1 Message Date
3d7a6ca43b libsysprof-profile: set default environment for spawnable 2023-06-06 16:45:02 -07:00
1e675e92e4 libsysprof-profile: add malloc tracing instrument 2023-06-06 16:30:38 -07:00
b0a3736ff4 libsysprof-profile: add memprof to profiler test 2023-06-06 16:15:45 -07:00
006618c5ae libsysprof-profile: fix -- parsing with options 2023-06-06 16:15:28 -07:00
0e625cea21 libsysprof-profile: add RAPL-based SysprofEnergyUsage
This does what we did previously with RAPL via sysprofd, with the new
SysprofInstrument API.
2023-06-06 15:56:38 -07:00
6f661c6bfe libsysprof-profile: add proxied instrument
This fetches data into a memfd from a peer process and then appends it to
the capture at the end of recording.
2023-06-06 15:55:57 -07:00
b38850f27d libsysprof-profile: ensure instruments finish recording
They may still be doing operations that need to complete before we can
move on to the augmentation phase.
2023-06-06 15:35:43 -07:00
f1826bfc86 libsysprof-profile: implement battery charge counters
This parses the battery charge values on a regular interval and exits when
the recording is stopped.
2023-06-06 13:01:41 -07:00
200b8acb20 libsysprof-profile: add scaffolding for battery charge
This is a SysprofInstrument that will eventually contain the contents of
the sysprof-battery-source.c to get battery charge/rate/etc. Note that
this is different from energy usage which will come from RAPL.
2023-06-06 11:19:03 -07:00
3de9f39348 libsysprof-profile: parse address ranges with GRegex
This uses G_REGEX_OPTIMIZE as well to get the benefit of the JIT when using
PCRE2 via GLib.

This turns out to take about half (or less) of the time that it takes to
use sscanf() to parse the template/input string. 0.03 vs 0.08 seconds on
my system.

If someone wants to take this further, and just look at the input string
rather than rely on GRegex, that'd be fine by me too.
2023-06-05 16:32:08 -07:00
0c6fcea79b libsysprof-profile: avoid splitting string into lines
We will always have either \n or \0 at the end, so we can just sscanf this
without needing to split strings.

The sscanf() is still our top offender though, and so we should probably
look for other ways to parse this string than sscanf().
2023-06-05 15:27:16 -07:00
745967253c libsysprof-profile: copy/paste fix 2023-06-05 15:05:21 -07:00
849db07ad6 libsysprof-profile: stash kallsyms from Perf instrument
That is the instrument that really provides things within the kernel
address space, so it should be the instrument which copies the contents
of kallsyms to the capture file (compressed).
2023-06-05 15:04:14 -07:00
4f4f3145c1 libsysprof-profile: backoff perf GSource when possible
We have a fairly large buffer for perf events, so we should be able to
process these much less frequently to help reduce the process performing
the profile from showing up in the profiling results.
2023-06-04 13:28:35 -07:00
13b76f7de6 libsysprof-profile: make timeout msec tweakable
We may want to tweak this as we discover we can either backoff or
increase our timing intervals.
2023-06-04 12:35:04 -07:00
a3c235a316 libsysprof-profile: don't use FD to drive perf source
It is not enough to get writability, as that wont trigger on the perf
source. Instead, we need to check the mmap'd header and drive things off
of that.

It might be nice to eventually determine how many of the samples are from
our own process and back-off our timeout based on that.
2023-06-04 10:20:34 -07:00
8138ab49c3 libsysprof-profile: always continue the source 2023-06-04 00:04:52 -07:00
a6ca0eb2d7 libsysprof-profile: setup mmap for perf mapping 2023-06-04 00:02:58 -07:00
5b5916bdcd libsysprof-profiler: convert perf event attr to variant 2023-06-03 23:53:38 -07:00
fb81867bf5 libsysprof-profiler: start on perf instrument
This starts porting the old perf code from libsysprof into
libsysprof-profile. It does not bring over tracepoints yet, because we
need to think about how we want to support that. I may opt to do that as
a separate instrument even if that takes an additional perf fd.
2023-06-03 23:14:14 -07:00
ece30b52b1 libsysprof-profile: fix GDBusConnection usage 2023-06-03 23:13:12 -07:00
d1db76a08d libsysprof-profile: make enable/disable accessible 2023-06-03 23:12:54 -07:00
25d629beb4 libsysprof-profile: start on perf event stream
This is a bit different than how we did things previously, but the same
mechanics are involved. Instead of multiple CPU registered together, we'll
just use one-stream-per-cpu.

Partly because I intend to drop support for profiling a single process as
that doesn't really get used much nor does it seem to yield very good
results from perf.
2023-06-03 21:28:22 -07:00
0288e937e4 libsysprof-profile: add SysprofMemoryUsage
Ports sysprof-memory-source.c to the new SysprofInstrument API.
2023-06-02 18:01:18 -07:00
37ad704186 libsysprof-profile: add ld_preload helper
This is to be used by instruments to adjust the spawnable to inject preload
into the spawned environment.
2023-06-02 17:09:44 -07:00
1a3facf6ff libsysprof-profiler: allow specifying test-profiler argv
You can `./test-profiler -- ls -lsah` to profile a subprocess and have
the profiler exit when the subprocess exits.
2023-06-02 16:50:41 -07:00
02b1d571cc libsysprof-profile: use char in sysprof-spawnable.h 2023-06-02 16:50:08 -07:00
ff490eb1fd libsysprof-profile: handle GIOStream properly 2023-06-02 16:49:56 -07:00
390e764aa7 libsysprof-profile: spawn spawnable and escape upon exit
We can use the new infinite future here to mimic running forever when there
is no spawnable. Otherwise, if the spawnable exits we want to break out
of the recording loop.
2023-06-02 16:27:41 -07:00
5746add9c6 libsysprof-profile: give Profiler a spawnable
And pass it along to the recording so that it can manage spawning the
subprocess during the record loop.
2023-06-02 16:15:27 -07:00
ba9d29fa33 libsysprof-profile: add trace_fd helper for spawnable
I'd like to stop using tracefd, but since we need to maintain compatability
with older tooling, lets at least make it more ergonomic than adding an
instrument(s) for it.
2023-06-02 15:57:46 -07:00
0146050618 libsysprof-profile: add SysprofDiskUsage
This is essentially the SysprofDiskstatSource in libsysprof ported to the
new instruments API.
2023-06-02 15:42:38 -07:00
337ddb4c37 libsysprof-profile: use new errno helpers 2023-06-02 14:42:33 -07:00
a256d19f68 libsysprof-profiler: provide recording state to fiber 2023-06-02 14:32:32 -07:00
728a9ce86a libsysprof-profiler: add scaffolding for disk usage
This still needs porting from libsysprof, but this gets the scaffolding in
place to bring over those counters.
2023-06-02 13:38:03 -07:00
e10ab3e32e libsysprof-profile: add augmentation phase to instruments
This allows an instrument to augment the capture with additional
information before the capture is closed/flushed to storage.
2023-06-02 12:59:01 -07:00
60ecde017f libsysprof-profile: add wrappers for instrument vfuncs
For maintainability, I'd prefer to keep these calls going through a wrapper
function. They get inlined likely by the compiler anyway.
2023-06-02 12:58:20 -07:00
fd40e940d3 libsysprof-profile: add network usage instrument 2023-05-31 22:43:33 -07:00
e3404dd0ca libsysprof-profile: update time range for recording
That way we don't have gaps at the edges.
2023-05-31 10:16:51 -07:00
bff99f1f63 libsysprof-profile: remove debug code 2023-05-31 10:12:17 -07:00
302a772c8d libsysprof-profile: fix await usage 2023-05-31 10:12:09 -07:00
e195b8961c libsysprof-profile: fix index of cpu ids 2023-05-31 10:11:47 -07:00
5389d6ac51 libsysprof-profile: fix logic of future checks 2023-05-31 09:58:51 -07:00
fd1fb68a98 libsysprof-profile: add various CPU parsing
This still needs some work because the read operations are blocked
currently.
2023-05-30 21:29:49 -07:00
52684c7a12 libsysprof-profile: start on cpu usage instrument
The goal here is to do the whole thing on a fiber rather than how we were
doing it before. This just gets the counter registration going, but we
need to follow up with the parsing/lseek/etc code.
2023-05-30 18:41:56 -07:00
598a2b7cf7 libsysprof-profile: capture podman overlays and containerenv
Additionally keep information about .flatpak-info so that we can
reconstruct which symbols are needed without build-id support.
2023-05-30 17:58:37 -07:00
9f9f953d53 libsysprof-profile: import podman utils
This comes from libsysprof, which we hope to remove as part of this move
to libsysprof-profile vs libsysprof-analyze.
2023-05-30 17:57:41 -07:00
1840c7b526 libsysprof-profile: add mmap records for existing processes 2023-05-30 17:35:00 -07:00
8ddcf54c37 libsysprof-profile: add mountinfo when process discovered 2023-05-30 17:28:04 -07:00
2ac4ff692d libsysprof-profile: add API to notify of process started
This will be used when we discover a process started like when the Perf
instrument gets PERF_RECORD_COMM.
2023-05-30 17:27:33 -07:00