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 is useful to find allocations free'd right after they were created.
A temporary allocation is currently defined as a free() right after an
allocation of that same memory address. From a quick glance, that appears
to be similar to what I've been seeing in heaptrack all these years.
In the long term, I'd expect we can do something more useful such as
"freed from similar stack trace" since things like g_strdup_printf()
would obviously break important temporary allocations.
We might get this information from multiple sources (such as Linux's perf
or the proc data source). So only add this information once to avoid
having additional data we don't care about.
This also helps ensure we get a proper tree for the callgraph without
splitting things between updated cmdline information.
We want to be backtracing directly into the capture buffer, but also need
to skip a small number of frames.
If we call the backtrace before filling in information, we can capture to
the position *before* ev->addrs and then overwrite that data right after.
This seems to be significantly faster than doing the manual stepping. A
quick look shows that it has a number of special cases which we'd have
to duplicate, so best to just use it directly.
128 is a bit much and can slow us down considerably with user-space stack
traces. This can mess up the tree a bit, but we can alter how we view
things later on if we need to so that it is easier to read.
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.