On 6/17/22 06:55, Kevin Kofler via devel wrote:
Ben Cotton wrote (on behalf of Daan De Meyer, Davide Cavalca, Andrii
Nakryiko):
> Fedora will add -fno-omit-frame-pointer to the default C/C++
> compilation flags, which will improve the effectiveness of profiling
> and debugging tools.
[…]
> Any performance or efficiency work relies on accurate profiling data.
So, you propose to destroy programs' performance in order to allow people to
more easily improve programs' performance? That strikes me as a particularly
bad idea.
A much better solution would be to enhance perf to run the unwinder in
user mode. The whole reason that this is even a tradeoff is because
perf does unwinding in kernel mode, and a kernel-mode DWARF parser
is an terrible idea for security reasons.
The profiling data collected with -fno-omit-frame-pointer will also
not be
accurate for when the software is compiled with the default (under -O2 and
above) -fomit-frame-pointer. (In particular, the cost of shorter functions
will be significantly higher (in relation to the total) with the frame
pointer than with omitted frame pointer.) So it can actually lead to the
software getting tuned only for the Fedora build configuration.
In addition, the frame pointer also increases code size (though, to be fair,
the asynchronous unwind tables that we usually want for code compiled with
-fomit-frame-pointer also take space).
> Sampling profilers probe the target program's call stack at regular
> intervals and store the stack traces. If we collect enough of them, we
> can closely approximate the real cost of a library or function with
> minimal runtime overhead.
Sampling profilers are fast, but will never reach the accuracy of Valgrind
(which, as far as I know, can deal with DWARF unwinding just fine).
Kevin Kofler
Valgrind is not helpful for profiling production workloads. It is
too slow and will not provide an accurate indication of where the
time is being spent. That requires a sampling profiler.
--
Sincerely,
Demi Marie Obenour (she/her/hers)