libsysprof-capture no longer calls any of the GLib logging functions
which make use of it.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Another step away from GLib. This changes the OOM behaviour of the
library — previously it would immediately `abort()` on OOM. However, it
seems likely that given the small number of allocations
libsysprof-capture does, it should be able to recover from an OOM
situation more gracefully than larger libraries can — so the new
implementation tries to do that.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Use the intrinsic atomics provided by the compiler, instead of GLib’s
wrapper around them. This should work for all modern compilers.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Another step towards dropping GLib as a dependency of
libsysprof-capture.
Unlike the previous commit which replaced GLib integer types with the
bitwise equivalent C standard types, `stdbool` is potentially a different
width from `gboolean`, so this is an ABI break.
It therefore involves some changes to callback functions in the tests
and tools, and in libsysprof.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
This is an almost entirely mechanical* conversion from (for example)
`gint` → `int`, `guint8` → `uint8_t`, etc.
It is not entirely complete, as many GLib functions are still used in
libsysprof-capture, which necessitate some use of GLib types.
It also avoids renaming `gboolean` → `bool` as that’s a slightly more
controversial change which will happen in the following commit.
*Code was manually realigned afterwards.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
As preparation for dropping the GLib dependency from libsysprof-capture,
move the `GSource` which links a `MappedRingBuffer` to a `GMainContext`
from libsysprof-capture to libsysprof.
This requires adding one new piece of API to libsysprof-capture to check
whether the `MappedRingBuffer` is empty.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
If we backport to an older GLib release, we won't have the newer atomic
helpers available. It's really not too much burden to do that manually if
it means we can run on older systems.
If we're running on a GCC older than 4.9, then we won't have the
stdatomic.h available. We can just use a full barrier instead using
__sync_synchronize() to get the same effect, albeit slower.
This ensures that the producer can produce as soon as the reader has moved
past that data. Now that the callback has a mutable consumption value, they
can read the whole data in one shot anyway.
This ideally should be dynamic in the future to copy out data at a rate
that keeps us around 33% usage rate so that we can still burst if we need
to but keep things empty enough to not loose data.
This removes the 8 bytes of framing data from the MappedRingBuffer which
means we can write more data without racing. But also this means that we
can eventually use the mapped ring buffer as our normal buffer for
capture writing (to be done later).
This is the start of a ring buffer to coordinate between processes without
the overhead of writing directly to files within the inferior process.
Instead, the parent process can monitor the ring buffer for framing
information and pass that along to the capture writer.