简体   繁体   English

nodejs profiling; 什么可以'未知'

[英]nodejs profiling; what can 'Unknown' be

While profiling a nodejs program, I see that 61% of the ticks are caused by 'Unknown' (see below). 在分析nodejs程序时,我发现61%的滴答声是由“未知”引起的(见下文)。 What can this be? 这可能是什么? What should I look for? 我应该寻找什么?

gr, GR,

Coen 科恩

Statistical profiling result from node, (14907 ticks, 9132 unaccounted, 0 excluded).

 [Unknown]:
   ticks  total  nonlib   name
   9132   61.3%

 [Shared libraries]:
   ticks  total  nonlib   name
   1067    7.2%    0.0%  C:\Windows\SYSTEM32\ntdll.dll
     55    0.4%    0.0%  C:\Windows\system32\kernel32.dll

 [JavaScript]:
   ticks  total  nonlib   name
   1381    9.3%   10.0%  LazyCompile: *RowDataPacket.parse D:\MI\packet.js:9
......

Are you loading any modules that have built dependencies? 您是否正在加载任何已构建依赖项的模块?

Basically by "Unknown" it means "unaccounted for" (check tickprocessor.js for more explanation). 基本上“未知”意味着“下落不明”(查看tickprocessor.js以获得更多解释)。 For example, the GC will print messages like "scavenge,begin,..." but that is unrecognized by logreader.js . 例如,GC将打印“scavenge,begin,...”之类的消息,但logreader.js无法识别这些消息。

It would help to know what profiling library your using to parse the v8.log file. 了解您使用什么分析库来解析v8.log文件会有所帮助。

Update 更新

The node-tick package hasn't been updated for over a year and is probably missing a lot of recent prof commands. node-tick包的更新时间已超过一年,可能缺少很多最近的prof命令。 Try using node-profiler instead. 请尝试使用node-profiler It's created by one of node's maintainers. 它由节点的维护者之一创建。 And if you want the absolute best result you'll need to build it using node-gyp . 如果你想要绝对最好的结果,你需要使用node-gyp来构建它。

Update 更新

I've parsed the v8.log output using the latest from node-profiler (the latest on master , not the latest tag) and posted the results at http://pastebin.com/pdHDPjzE 我使用最新的node-profiler (最新的master ,而不是最新的标签)解析了v8.log输出,并将结果发布在http://pastebin.com/pdHDPjzE

Allow me to point out a couple key entries which appear about half way down: 请允许我指出几个关键条目,大约一半出现:

[GC]:
  ticks  total  nonlib   name
  2063   26.2%

[Bottom up (heavy) profile]
6578   83.4%  c:\node\node.exe
1812   27.5%    LazyCompile: ~parse native json.js:55
1811   99.9%      Function: ~<anonymous> C:\workspace\repositories\asyncnode_MySQL\lib\MySQL_DB.js:41
 736   11.2%    Function: ~Buffer.toString buffer.js:392

So 26.2% of all script type was spent in garbage collection. 因此,所有脚本类型的26.2%用于垃圾收集。 Which is much higher than it should be. 这比它应该高得多。 Though it does correlate well with how much time is spent on Buffer.toString . 虽然它确实与在Buffer.toString上花费了多少时间有关。 If that many Buffers are being created then converted to strings, both would need to be gc'd when they leave scope. 如果正在创建那么多Buffers然后转换为字符串,那么当它们离开范围时都需要gc'd。

Also I'm curious why so much time is spent in LazyCompile for json.js . 另外我很好奇为什么LazyCompile花了这么多时间用于json.js Or more so, why would json.js even be necessary in a node application? 或者更重要的是,为什么在节点应用程序中甚至需要json.js

To help you performance tune your application I'm including a few links below that give good instructions on what to do and look for. 为了帮助您调整应用程序的性能,我在下面添加了一些链接,可以提供有关如何操作和查找的详细说明。

Nice slide deck with the basics: 漂亮的滑梯与基础:
https://mkw.st/p/gdd11-berlin-v8-performance-tuning-tricks/#1 https://mkw.st/p/gdd11-berlin-v8-performance-tuning-tricks/#1

More advanced examples of optimization techniques: 更高级的优化技术示例:
http://floitsch.blogspot.com/2012/03/optimizing-for-v8-introduction.html http://floitsch.blogspot.com/2012/03/optimizing-for-v8-introduction.html

Better use of closures: 更好地使用闭包:
http://mrale.ph/blog/2012/09/23/grokking-v8-closures-for-fun.html http://mrale.ph/blog/2012/09/23/grokking-v8-closures-for-fun.html

Now as far as why you couldn't achieve the same output. 现在,至于为什么你无法实现相同的输出。 If you built and used node-profiler and its provided nprof from master and it still doesn't work then I'll assume it has something to do with being on Windows. 如果您构建并使用了node-profiler及其提供的来自master nprof ,但它仍然不起作用,那么我将假设它与在Windows上有关。 Think about filing a bug on GitHub and see if he'll help you out. 考虑在GitHub上提交一个错误,看看他是否会帮助你。

You are using a 64 bit version of Node.JS to run your application and a 32bit build of the d8 shell to process your v8.log . 您正在使用64位版本的Node.JS来运行您的应用程序和32位版本的d8 shell来处理您的v8.log Using either a 32 bit version of Node.JS with ia32 as the build target for the d8 shell or a 64 bit version of Node.JS with x64 as the d8 shell build target should solve your problem. 使用32位版本的Node.JS和ia32作为d8 shell的构建目标,或使用64位版本的Node.JS和x64作为d8 shell构建目标应该可以解决您的问题。

Try to build v8 with profiling support on: 尝试构建具有分析支持的v8:

scons prof=on d8

Make sure you run node --prof with version corresponding to version of v8 确保使用与v8版本对应的版本运行node --prof

Then tools/linux-tick-processor path/to/v8.log should show you the full profile info. 然后tools/linux-tick-processor path/to/v8.log应该显示完整的个人资料信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM