Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome: CPU profile parser is fixing n missing samples

I'm using Chrome's performance tab to study the performance of a page, and I occasionally get a warning like:

DevTools: CPU profile parser is fixing 4 missing samples.

Does anyone know what this means? Googling for this warning has returned no results so far...

like image 395
duhaime Avatar asked Aug 30 '18 20:08

duhaime


1 Answers

As coming across with and having this situation, possible helpful things to consider are as below.

As Chrome 58 is released in 2017, some changes are done related to the analyzing performance. For example:

  1. Timeline panel is renamed as Performance panel.
  2. Profiles panel is renamed as Memory panel.
  3. Record Javascript CPU Profile menu is moved into Dev Tools → Three dots at right → More tools → Javascript Profiler. (Old version of Javascript Profiler)

In addition of these, the warning message that is seen (DevTools: CPU profile parser is fixing N missing samples.) is being written to the console window when there is single (program) sample between two call stacks sharing the same bottom node. Also, the samples count should be greater than or equal to 3 according to the source code.

Comments written above _fixMissingSamples method in the CPUProfileDataModel.js file explains this situtation as below;

// Sometimes sampler is not able to parse the JS stack and returns
// a (program) sample instead. The issue leads to call frames belong
// to the same function invocation being split apart.
// Here's a workaround for that. When there's a single (program) sample
// between two call stacks sharing the same bottom node, it is replaced
// with the preceeding sample.

In the light of these information, we can trace the code and examine the behavior.

CPUProfileDataModel.js

 let prevNodeId = samples[0];
 let nodeId = samples[1];
 let count = 0;
 for (let sampleIndex = 1; sampleIndex < samplesCount - 1; sampleIndex++) {
   const nextNodeId = samples[sampleIndex + 1];
   if (nodeId === programNodeId && !isSystemNode(prevNodeId) && !isSystemNode(nextNodeId) &&
       bottomNode(idToNode.get(prevNodeId)) === bottomNode(idToNode.get(nextNodeId)) {
     ++count;
     samples[sampleIndex] = prevNodeId;
   }
   prevNodeId = nodeId;
   nodeId = nextNodeId;
 }
 if (count) {
   Common.console.warn(ls`DevTools: CPU profile parser is fixing ${count} missing samples.`);
 }

It seems that, it simply compares previous and next node related to current node as if they has the same bottom node (actually comparing parent nodes). Also previous and next node shouldn't be a system (program/gc/idle function) node and current node should be the 'program' node. If it is the case, then the current node in samples array is set to previous node.

Javascript Profiler sample screenshot

idle: Waiting to do process
program: Native code execution
garbage collector: Accounts for Garbage Collection

Chrome Performance tab screenshot

Also, disabling Javascript samples from Performance → Capture Settings result fewer details & call stacks because of omitting all the call stacks. The warning message shouldn't appear in this case.

But, since this warning is about the sampler that says cannot parse the JS stack and call frames being split apart, it doesn't seem very important thing to consider.

Resources:

https://github.com/ChromeDevTools/devtools-frontend/tree/master/front_end/sdk
https://github.com/ChromeDevTools/devtools-frontend/blob/master/front_end/sdk/CPUProfileDataModel.js
https://chromium.googlesource.com/chromium/blink/+/master/Source/devtools/front_end/sdk/
https://developers.google.com/web/tools/chrome-devtools/evaluate-performance
https://developers.google.com/web/updates/2016/12/devtools-javascript-cpu-profile-migration

like image 168
Erdem Savasci Avatar answered Oct 19 '22 22:10

Erdem Savasci