我的节点应用程序(通过webpack dev服务器运行)持续占用60%的CPU。从cpu配置文件看起来,调用_proc_listpidspath
是罪魁祸首。有关此函数调用的任何提示,以及如何查找哪个节点库调用此函数。
感谢。
请参阅下面的个人资料。
Code move event for unknown code: 0x19cac90226c0
Code move event for unknown code: 0x19cac90b3360
Code move event for unknown code: 0x19caca55d3a0
Statistical profiling result from isolate-0x102004c00-v8.log, (209273 ticks, 2592 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
6896 3.3% /usr/lib/system/libsystem_c.dylib
285 0.1% /usr/lib/system/libsystem_pthread.dylib
[JavaScript]:
ticks total nonlib name
332 0.2% 0.2% KeyedLoadIC: A keyed load IC from the snapshot {1}
287 0.1% 0.1% Stub: LoadICStub
....
....
[Summary]:
ticks total nonlib name
5271 2.5% 2.6% JavaScript
194229 92.8% 96.1% C++
1481 0.7% 0.7% GC
7181 3.4% Shared libraries
2592 1.2% Unaccounted
[C++]:
ticks total nonlib name
162560 77.7% 80.4% _proc_listpidspath
4417 2.1% 2.2% _uv_timer_stop
1683 0.8% 0.8% _heap_node_swap
1274 0.6% 0.6% _timer_cb
1006 0.5% 0.5% _hex
762 0.4% 0.4% _uv_fs_stat
704 0.3% 0.3% _mach_vm_map
677 0.3% 0.3% _szone_check_all
654 0.3% 0.3% _pthread_join$NOCANCEL
637 0.3% 0.3% __pthread_exit
583 0.3% 0.3% _uv__run_timers
583 0.3% 0.3% _dec
......
......
[Bottom up (heavy) profile]:
Note: percentage shows a share of a particular caller in the total
amount of its parent calls.
Callers occupying less than 2.0% are not shown.
ticks parent name
162560 77.7% _proc_listpidspath
6896 3.3% /usr/lib/system/libsystem_c.dylib
4417 2.1% _uv_timer_stop
编辑:
我可以将它隔离到它发生的时候。我昨天开始使用yarn。现在,如果我删除node_modules
并运行npm -i
以通过npm客户端安装所有deps,我会在node_modules
中看到文件计数为
node_modules ❯❯❯ find . -print | wc -l master
43058
如果我删除node_modules
并运行~/.yarn/bin/yarn.js
,那么
node_modules ❯❯❯ find . -print | wc -l ⏎ master
32138
因此,cli安装的文件存在差异,而纱线安装量较少。但是,带有纱线的cpu闲置率为80%(监视模式下的webpack服务器),npm为1%。!!
答案 0 :(得分:0)
这可能是由于纱线跳过了chokidar
。
这些问题在yarnpkg
跟踪器上公开,等待修复。
https://github.com/yarnpkg/yarn/issues/1009 https://github.com/yarnpkg/yarn/issues/629