本文介绍了Chrome:CPU配置文件解析器正在修复n个缺失的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Chrome的性能"标签来研究页面的性能,偶尔会收到类似以下的警告:

有人知道这意味着什么吗?谷歌搜索此警告至今未返回任何结果...

解决方案

遇到这种情况时,可能需要考虑的有益事情如下.

随着 Chrome 58 在2017年发布,对分析性能进行了一些更改.例如:

  1. 时间轴面板被重命名为性能面板.
  2. 个人资料面板被重命名为内存面板.
  3. 记录Javascript CPU配置文件菜单移至开发工具"→右侧的三个点→更多工具→Javascript Profiler. (版本的Javascript Profiler)

此外,当 在共享同一底部节点的两个调用堆栈之间存在单个(程序)样本. 此外,根据源代码,样本计数应大于或等于3. /p>

CPUProfileDataModel.js 文件的 _fixMissingSamples 方法上方编写的注释解释了以下情况;

// 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.

根据这些信息,我们可以跟踪代码并检查行为.

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.`);
 }

似乎,它只是将与当前节点相关的上一个和下一个节点进行比较,就好像它们具有相同的底部节点一样(实际上是比较父节点).同样,上一个和下一个节点也不应该是系统(program/gc/idle函数)节点,而当前节点应该是"program"节点.如果是这样,则将samples数组中的当前节点设置为上一个节点.

空闲:正在等待处理
程序:执行本机代码
垃圾收集器:垃圾收集帐户

此外,从性能"→捕获设置"中禁用Javascript示例会导致较少的详细信息&因为省略了所有调用堆栈,所以调用堆栈.在这种情况下,不应显示警告消息.

但是,由于此警告与采样器有关,该采样器说无法解析JS堆栈并且调用帧被拆分,因此考虑起来似乎不是很重要.

资源:

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/评估效果
https://developers.google.com/web/updates/2016/12/devtools-javascript-cpu-profile-migration

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

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

解决方案

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.

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

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

这篇关于Chrome:CPU配置文件解析器正在修复n个缺失的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 07:39