Previous: , Up: Tunables   [Contents][Index]


38.8 gmon Tunables

Tunable namespace: glibc.gmon

This tunable namespace affects the behaviour of the gmon profiler. gmon is a component of the GNU C Library which is normally used in conjunction with gprof.

When GCC compiles a program with the -pg option, it instruments the program with calls to the mcount function, to record the program’s call graph. At program startup, a memory buffer is allocated to store this call graph; the size of the buffer is calculated using a heuristic based on code size. If during execution, the buffer is found to be too small, profiling will be aborted and no gmon.out file will be produced. In that case, you will see the following message printed to standard error:

mcount: call graph buffer size limit exceeded, gmon.out will not be generated

Most of the symbols discussed in this section are defined in the header sys/gmon.h. However, some symbols (for example mcount) are not defined in any header file, since they are only intended to be called from code generated by the compiler.

Tunable: glibc.mem.minarcs

The heuristic for sizing the call graph buffer is known to be insufficient for small programs; hence, the calculated value is clamped to be at least a minimum size. The default minimum (in units of call graph entries, struct tostruct), is given by the macro MINARCS. If you have some program with an unusually complex call graph, for which the heuristic fails to allocate enough space, you can use this tunable to increase the minimum to a larger value.

Tunable: glibc.mem.maxarcs

To prevent excessive memory consumption when profiling very large programs, the call graph buffer is allowed to have a maximum of MAXARCS entries. For some very large programs, the default value of MAXARCS defined in sys/gmon.h is too small; in that case, you can use this tunable to increase it.

Note the value of the maxarcs tunable must be greater or equal to that of the minarcs tunable; if this constraint is violated, a warning will printed to standard error at program startup, and the minarcs value will be used as the maximum as well.

Setting either tunable too high may result in a call graph buffer whose size exceeds the available memory; in that case, an out of memory error will be printed at program startup, the profiler will be disabled, and no gmon.out file will be generated.


Previous: Memory Related Tunables, Up: Tunables   [Contents][Index]