Community
cancel
Showing results for 
Search instead for 
Did you mean: 
108 Views

Using GUI and forking applications

I'm evaluating VTune 9.1 for linux. I have tried to use VTune vtlec with apache serevr httpd. Doing the sampling went fine, however I could not make the callgraph collecting towork properly. I have noticed that the prcoess of httpd works as follows httpd.xxx (where xxx is the process id)

When activating "httpd -k start" --> httpd.1200 is created

httpd.1200 fork to httpd.1201
httpd.1200 exits
httpd.1201 fork to httpd.1202,1203,1204,1205

The callgraphterminated as soon as httpd.1200 exited, where my main interest is to collect the callgtraph from the forked httpd.1201,1202,1203,1204.

Is there a way to make it work ?

Thanks

Oron

0 Kudos
3 Replies
Peter_W_Intel
Employee
108 Views

I'm evaluating VTune 9.1 for linux. I have tried to use VTune vtlec with apache serevr httpd. Doing the sampling went fine, however I could not make the callgraph collecting towork properly. I have noticed that the prcoess of httpd works as follows httpd.xxx (where xxx is the process id)

When activating "httpd -k start" --> httpd.1200 is created

httpd.1200 fork to httpd.1201
httpd.1200 exits
httpd.1201 fork to httpd.1202,1203,1204,1205

The callgraphterminated as soon as httpd.1200 exited, where my main interest is to collect the callgtraph from the forked httpd.1201,1202,1203,1204.

Is there a way to make it work ?

Thanks

Oron

Hi Oron,

Call graph data collection is foryour targetapplication, your main process will be tracked - but forked processes are not tracked during data collecting.

In other words, call graph is for single process. The user has to use sampling data collection, which can collect data for all active processes in the system

Regards, Peter

108 Views

Sorry for being stubborn but I have tried the following code

#include

extern "C" void f_parent(){
for (int i=0;i<10000;i++){}
}

extern "C" void f_child(){
for (int i=0;i<10000;i++){}
}

int main(int argc,char* argv[]){
if (fork()!=0){
for (int i=0;i<100;i++){ f_parent(); }
}else{
for (int i=0;i<100;i++){ f_child(); }
}

return 0;
}

Following your answer I should have seen only f_parent(); in the call graph, however when I set the function to collect to both f_parent() and f_child() (as depicted from the attached i0.jpg), I got both f_parent() and f_child() in the call-graph (see i1.jpg) however both were collected toward a single process (I guess the first one launched).

More over I have read in the documentation and I could also test it with some application that call-graph will emit call-graph information for more than a single process. In my sample application, probably processes that where launched using exec() from the parent process (see i2.jpg). I could get call-graph for any of the above applications. I could select the appropriated application to view (after call-graph has been created) using the Process drop-down control above the call-graph on the GUI.

From my experiments so far it seems that when fork is used, all measurements from the forked process will continue to contribute events toward the parent process. Call-graph will terminate as soon as the parent process is terminated.

Though you already told me that it is impossible, in light of my findings, is there a way around where values from the sub-processes will continue to accumulate toward the parent process collection even after it terminated (I have tried to limit the collection to # of seconds instead process termination in a hope that it will continue to accumulate after the process has terminated but it did not work )

This ability of getting accurate call-graph (not sampled) across forking is curtail for my tests.

Is there still hope?

Oron

Peter_W_Intel
Employee
108 Views

Thanks for your example code.I may notdescribethis clearly,last post - Sorry.

The fork() call will spawn a new child process (copied in new memory space from the parent) which is an identical process to the parent except that has a new system process ID. So you will see f_parent() and f_child()werecalleesof main() in call graph report, theywere instrumented successfully, they are in same module and can be tracked.

Alternatively if you move f_parent() to another module "a2" (we canassume original modulename "a1", f_parent() is in "a2", called by main() of "a2"), you canwrite "a1" as:

int main (int argc, char *argv[]) {

...

execl ("./a2", "./a2", (char *)0);

...

return 0;

}

Thus, call graph report willNOT display functions in "a2" - even you add "a2" module into interest of modules, by modifying the activity.

That is what I said in last time, module "a1" (launched application) can be tracked, but "a2" can not be tracked.

Regards, Peter

Reply