From: Maynard J. <may...@us...> - 2013-02-21 17:43:40
|
On 02/14/2013 12:15 PM, Carl E. Love wrote: > On Tue, 2013-02-12 at 16:38 -0600, Maynard Johnson wrote: >> The difference between this "version 2" patch and the original patch is >> that it fixes the bug Carl identified earlier today where --system-wide >> mode took several seconds before it would start to record any samples. >> >> In my original patch, I had changed things around with how we were collecting >> and recording information about already-running processes -- separating out >> the info collection phase from the phase where we write PERF_RECORD_COMMs >> (for apps) and PERF_RECORD_MMAPs (for the shared libraries used by the apps). >> These PERF_RECORD_* events are written by operf_record into the sample data >> stream that operf_read processes in convertSampleData. Anyway, my patch was >> mistakenly blindly calling op_record_process_exec_mmaps() for *every* process >> I had stored into the 'procs' vector. But many of the processes collected >> into the 'procs' vector were child processes, so their memory mappings would >> be the same as the parent. The upshot was that I was creating many unnecessary >> PERF_RECORD_MMAPs. So I put some code into to make sure I didn't call >> op_record_process_exec_mmaps() unnecessarily -- i.e., if it was called once >> for a given tgid, it didn't need to be called again. This change was made >> in operf_counter.cpp:operf_record::record_process_info. I also moved the >> location of the "Profiler started" message from operf.cpp:_run to >> operf_counter.cpp:operf_record::recordPerfData. >> >> *Suravee and Carl*, please review. > > Maynard: > > I don't see anything specific with the patch. The updated patch does > seem to fix the issue I had with short sampling. Looks good. > > Carl Love Patch committed. Thanks, Carl. -Maynard > >> >> -Maynard >> >> -------------------------------------------------------------------- >> operf does not properly sample already-running Java apps >> >> When passing the 'java' command directly to operf, samples are nicely >> collected for all of the threads created by the JVM. However, if the >> Java app is already running when the user starts operf with either >> '--pid' or '--system-wide' option, zero samples are collected on the >> child threads of the JVM. Note: The user program that is JITed by the >> JVM is executed by a child thread. >> >> This patch addresses the problem by: >> - Keeping a list of child processes >> - Synthesizing PERF_RECORD_COMM events for the main JVM process and all >> the child processes >> - Calling perf_event_open for the main JVM process and all child processes >> >> These changes entailed some fairly major restructuring of some functions >> and data structures of the operf_record class. >> >> Signed-off-by: Maynard Johnson <may...@us...> >> --- >> libperf_events/operf_counter.cpp | 247 ++++++++++++++++++++++++++------------ >> libperf_events/operf_counter.h | 22 +++- >> libperf_events/operf_event.h | 1 - >> libperf_events/operf_stats.cpp | 17 ++-- >> libperf_events/operf_stats.h | 2 +- >> libperf_events/operf_utils.cpp | 42 +++---- >> libperf_events/operf_utils.h | 3 +- >> pe_profiling/operf.cpp | 12 +- >> 8 files changed, 225 insertions(+), 121 deletions(-) >> [snip] |