Programs often create child processes using fork or vfork. When these child processes start, they execute from the current data state of the parent, typically to perform some computation based on data the parent provides. For example, the parent process might fork a child process to handle a request from the client to update a data record. Child processes, rather than the parent processes, are often the actual site of the performance bottlenecks in a program. To capture the performance data from these separate processes, Quantify must start a different instance of itself for each child process before the child process executes.
Sometimes child processes immediately call execve to start running a different program altogether. In this case, the effort of starting a new copy of Quantify for the child process is wasted. Therefore, by default, Quantify does not start Quantify to record child process data. To record child process data, set the -record-child-process-data option:
% setenv QUANTIFYOPTIONS -record-child-process-data=yes
By default, Quantify saves data for each child process in a different file, since the filename prefix includes the %p character, which expands to the process ID of each child.
Since the operating system makes a copy of the memory state during a fork, the counts for the child process include the counts from the parent process up to the point of the fork. To exclude the parent data from the child process data, you can call the quantify_clear_data API function after the child process begins.
The vfork system call creates a child process that shares the same memory image as its parent process. The parent process is suspended until the child exits. Since Quantify keeps its counter data in memory, as the child process executes it adds the counts to the parent's counters, thereby corrupting the parent's data. To prevent this, Quantify intercepts all vfork calls and converts them to fork calls. The fork system call ensures that the child is an independent process with its own memory state. Since the child is Quantify'd, its data is reported under a separate process ID, if -record-child-process-data=yes.