Re: [benchmarks] Memory handling and cachegrind parsing

From: Date: Wed, 10 Jun 2009 21:40:28 +0000
Subject: Re: [benchmarks] Memory handling and cachegrind parsing
References: 1  Groups: php.qa 
Request: Send a blank email to php-qa+get-65081@lists.php.net to get a copy of this message
Hi,
I've added the diffs to bench.php here as well as the cachegrindparser.php and smapsparser.php. None of these are completely implemented, but I'm on my way and think it's good to hear some feedback here. The cachegrind usage has no output at all currently.
cool progress so far :) BTW, you don't need to use OOP everywhere :) Just because they teach that Java is the only solution to world's problems, it doesn't mean you should use classes everywhere (I'm pointing particularly to your cachegrind parser).
I chose to implement the smaps memory handling because I couldn't find anything that was suiting better. If there would have been a fast tool that worked on windows as well as linux, it would have been better, but since google used this in their "unladen shadow" project, I thought it was a good idea to do it here as well. It works by sampling the memory data during the runs and place the info in an array, which then takes the maximum memory usage and prints it along with the files that consumed the most memory during that time.
sounds good. please add a note somewhere that it requires linux 2.6.14 or newer.
There is one "problem" about the pid for the test processes. I have to use "pid + 1" to get the actual pid, since the "pid" is just the shell execution and "pid + 1" is the real php execution. Could this be a problem?
You cannot rely on that. First, some kernels do PID randomization. Second, PIDs often overflow, and then they wrap-around. In summary, you have no way (that I'm aware) to know the PID of the php process. What you can do is to skip the shell and spawn the php process directly (I guess I never implemented this in PHP in linux - although it's implemented for windows - but I think I can take a look now). Nuno

« previous php.qa (#65081) next »