> Is the call graph data actually correct?  That is, are the routines
> which gather that data thread-safe?

No. You'll find the relevant source in glibc 2.1,
gmon/{mcount.c,gmon.c}:_gmonparam, which is a global structure.

> Are profiling timers per-thread?  Is it possible for me to enable it
> in the other threads?  Would that even work?

This is defined in profil.c, of glibc. These days, gcc only emits the
calls to mcount - implementations of this function are often provided
by the platform. In the specific case of Linux, feel free to ask the
glibc maintainers for their thoughts.

I'd say it is inherently difficult to activate global profiling. What
*might* work is per-thread profiling, and then writing back the
profile data. In any case, the overhead of profiling becomes even more
visible due to the multithreading calls, on each mcount invocation
(which tend to be system calls).

Regards,
Martin

Reply via email to