Commit Graph

2902 Commits

Author SHA1 Message Date
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
03c6c57fab contrib: move line reader to contrib
This came from Builder, and it's nice to be able to use it statically from
multiple libsysprof libraries.
2023-05-30 21:29:24 -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
ee3a78433f libsysprof-profile: add processes during recording
We want to reduce the chances we miss things between prepare and record
virtual methods, so delay the adding of processes until the recording is
started. We may get duplicate records, but we can deal with that when
analyzing the capture.
2023-05-30 17:12:19 -07:00
5c825c1fb5 libsysprof-profile: add some basic process information
This needs to get into the capture, and we still need to respond to the
discovery of new processes as well (which we lack API for).
2023-05-30 17:06:28 -07:00
81317bc1ca libsysprof-profile: add recording helper to capture file data
We might have the file data from the peer and can specify the data in the
capture writer directly.

It may be useful to allow compressing these too, but we can deal with that
at a later time.
2023-05-30 17:00:53 -07:00
df7da9bb41 libsysprof-profile: remove frame overhead from max data length
Just so that we can potentially fit multiple of these per buffering in the
capture writer.
2023-05-30 17:00:00 -07:00
f91e13e055 libsysprof-profile: require org.gnome.sysprof3.profile policy
This will be needed to read the given proc files that should be captured
in the recording.
2023-05-30 16:11:38 -07:00
1764a088ee libsysprof-profile: fix iteration of instruments 2023-05-30 16:10:19 -07:00
1851f39b8a libsysprof-profile: use dex_bus_get()
This allows us to remove the synchronous call here from the fiber calling
into this API.
2023-05-30 16:05:01 -07:00
f9be133913 libsysprof-profile: implement loading files via sysprofd
If we need access to a privileged file in /proc or /sys we need to get
that through sysprofd. This implements basic checking of paths to see
if we need to get a /proc file from there.

We can't use the GetProfFD variant because that may still cause errors
when reading back due to how selinux and other LSMs may restrict read()
to get kallsyms.

This requires recent API additions in libdex.
2023-05-30 15:53:39 -07:00
4fe9339113 libsysprof-profile: capture files using recording API 2023-05-30 14:44:01 -07:00
14f71c5eee libsysprof-profile: add API to append a file to recording 2023-05-30 14:43:44 -07:00
957cec9843 libsysprof-analyze: decompress if necessary in dup_bytes()
If we are trying to get the file bytes and they are compressed, we may need
to transparently decompress those bytes. That way if the API requested
"/proc/cpuinfo" but really got "/proc/cpuinfo.gz" it still gets the same
bytes to consume.
2023-05-30 13:19:57 -07:00
1e8e1adb73 libsysprof-analyze: automatically handle compressed streams
If we want /proc/kallsyms and we discover /proc/kallsyms.gz, then use the
/proc/kallsyms.gz instead and transparently decompress it. Also, list the
file in sysprof_document_list_files() as /proc/kallsyms instead of
/proc/kallsyms.gz as that is really the intention (but mark the compressed
bit for decoding the chunks).
2023-05-30 12:46:42 -07:00
01091fe815 libsysprof-profiler: add linux instrument on Linux 2023-05-28 09:08:35 -07:00
02811d593b libsysprof-profile: start on linux host info instrument
This instrument is meant to gather information about the host that we will
need as part of the capture to decode things properly.
2023-05-27 10:33:45 -07:00
80bc9ac370 libsysprof-profile: fix declaration alignment 2023-05-26 23:04:22 -07:00
62071ff56f libsysprof-profile: bridge ring data to capture file 2023-05-26 17:07:26 -07:00
7c98f782c0 libsysprof-profile: add getter for capture writer 2023-05-26 17:07:16 -07:00