|
From: Christoph S. <chr...@gm...> - 2011-08-30 16:51:47
|
On 30/08/2011 3:50 AM, WAROQUIERS Philippe wrote: >> However, the cost seems to include overhead from valgrind itself, such >> as malloc& other hooks. >> (I see in the call graph that malloc calls "malloc_hook_ini" >> once with a >> cost of around 60,000 Ir. >> Having only one a few mallocs in a particluar algorithm this overhead >> greatly distorts test results. >> >> A second problem are symbol resolutions in the C library. Apparently >> '_dl_runtime_resolve' is called once for each symbol used from >> the C lib >> (such as sprintf). This is also unwanted overhead. > Are you sure these hooks are from valgrind ? > I think there are rather from glibc and similar, and callgrind properly > shows that your code (indirectly) implies these calls. > > (I did a grep for malloc_hook_ini on recent Valgrind sources, and found > no hit in .c or .h files). > Probably not. I now believe that all those unwanted calls are to blame on the C library and dynamic loader. There were many unwanted calls to functions like '_dl_runtime_resolve', '_dl_addr' and the like. Looking at my call graph again, 'malloc_hook_ini' calls 'ptmalloc_init' which calls '_dl_addr', and the cost of 60,000 Ir is due to '_dl_addr'. I solved all those problems by using static linkage. Chris |