Optionally use unwind_tables instead of libunwind
This can then be used on platforms with no libunwind available. This
makes heaptrack functional, but the performance is really bad:
With unwind_tables:
$ perf stat ./bin/heaptrack ./tests/manual/threaded heaptrack output will be written to "/home/milian/projects/src/heaptrack/build-unwind-tables/heaptrack.threaded.8761.zst" starting application, this might take some time... heaptrack stats: allocations: 403359 leaked allocations: 0 temporary allocations: 0 Heaptrack finished! Now run the following to investigate the data: heaptrack --analyze "/home/milian/projects/src/heaptrack/build-unwind-tables/heaptrack.threaded.8761.zst" Performance counter stats for './bin/heaptrack ./tests/manual/threaded': 10.563,39 msec task-clock:u # 3,828 CPUs utilized 0 context-switches:u # 0,000 K/sec 0 cpu-migrations:u # 0,000 K/sec 11.483 page-faults:u # 0,001 M/sec 13.180.119.787 cycles:u # 1,248 GHz 11.499.050.817 instructions:u # 0,87 insn per cycle 2.617.513.665 branches:u # 247,791 M/sec 41.612.348 branch-misses:u # 1,59% of all branches 2,759435712 seconds time elapsed 6,641991000 seconds user 3,927803000 seconds sys
With libunwind:
$ perf stat heaptrack ./tests/manual/threaded heaptrack output will be written to "/home/milian/projects/build/heaptrack/heaptrack.threaded.7136.zst" starting application, this might take some time... heaptrack stats: allocations: 403293 leaked allocations: 0 temporary allocations: 0 Heaptrack finished! Now run the following to investigate the data: heaptrack --analyze "/home/milian/projects/build/heaptrack/heaptrack.threaded.7136.zst" Performance counter stats for 'heaptrack ./tests/manual/threaded': 1.336,98 msec task-clock:u # 2,730 CPUs utilized 0 context-switches:u # 0,000 K/sec 0 cpu-migrations:u # 0,000 K/sec 36.905 page-faults:u # 0,028 M/sec 1.909.003.446 cycles:u # 1,428 GHz 2.485.908.851 instructions:u # 1,30 insn per cycle 448.570.458 branches:u # 335,510 M/sec 4.876.436 branch-misses:u # 1,09% of all branches 0,489731820 seconds time elapsed 0,798096000 seconds user 0,564706000 seconds sys
As can be seen, using libunwind is roughly 5x faster for heaptrack
and this test case on my machine here.