What is function __tcf_0? (Seen when using gprof and g++)

Deadly 提交于 2019-12-01 15:57:41

问题


We use g++ 4.2.4 and I'm trying to track down some performance problems in my code.

I'm running gprof to generate the profile, and I'm getting the following "strangeness" in that the most expensive function is __tcf_0:

Each sample counts as 0.01 seconds.
 %   cumulative   self              self     total           
time   seconds   seconds    calls  ms/call  ms/call  name    
40.00      0.04     0.04        1    40.00    95.00  __tcf_0

This function then appears to calls most of my user functions (ie. it is the one that's called from main). The nearest explanation that I found for this was here, but that link refers to static objects and atexit, and I don't think this applies in my case.

If it's helpful, I'm using Boost (program_options and fusion) and the HDF5 libraries.

UPDATE:

The command I use when building is:

g++  -Wreturn-type -Wunused -Winline -pg  -DLINUX -DHAS_SETENV \
    -DFUSION_MAX_MAP_SIZE=15 -DFUSION_MAX_VECTOR_SIZE=15  -g -O0 \
    --param large-function-growth=300 --param inline-unit-growth=200

回答1:


__tcf_0 seems indeed to be a function which calls destructor of static objects and which is registered for each static objects, to be called at exit (taking for granted what is said on this page)

Now, the result of your gprof is quite strange, since the function which takes most of the time only takes 0.04 seconds, which means the whole program takes 0.1 s to execute. If I'm not mistaken, my guess is that you didn't profile correctly. Did you compile your code with profiling enabled?




回答2:


g++ generates functions with this name. They call the destructor of static objects and are registered with atexit() when the constructor is called.



来源:https://stackoverflow.com/questions/1227020/what-is-function-tcf-0-seen-when-using-gprof-and-g

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!