[simpleperf] Why do we need to read jit/dex descriptors 3 times? #1956
-
As per the code we are reading the jit/dex descriptors 3 times as below:
Why do we need to have point 1, because anyways we are not processing the mmap2 samples in report and we have the point 2 to get the latest data corresponding to each sample? There are 2 questions
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Thanks for the question! So simpleperf isn't reading the latest JIT/Dex entries for every sample. Instead, it uses item 1 (read JIT/Dex entries periodically) and item 3 (read immediately when having unwinding error). It's mostly a trade-off between process time and accuracy. But since there is a delay between generating a sample and unwinding it, and JIT/Dex entries can change in between, reading the latest JIT/Dex entries when processing a sample doesn't necessarily get a correct unwinding result. The item 2 (monitor a process when seeing the first sample of it), is mostly for processes added during recording (like For mmap2 record, it's used when reporting, as in https://cs.android.com/android/platform/superproject/main/+/main:system/extras/simpleperf/thread_tree.cpp;l=397;drc=7369db2599643b98b60b3b6237178919f9b7726d |
Beta Was this translation helpful? Give feedback.
Thanks for the question!
The understandings of for item 1 and 3 are correct.
But for item 2, when we read a sample record, we check if we have monitored this process before, by checking pids_with_art_lib_[r.tid_data.pid]. If not, we call MonitorProcess() to monitor this process, and call ReadProcess() to get the latest JIT/Dex entries once for the current sample. The next time we see a sample from the same process, pids_with_art_lib_[r.tid_data.pid]=true, so we won't call MonitorProcess() and ReadProcess() again. The code is https://cs.android.com/android/platform/superproject/main/+/main:system/extras/simpleperf/JITDebugReader.cpp;l=259;bpv=1;bpt=1.
So simpleperf isn't reading the latest…