2016-10-13 2 views
1

Meine Knoten-App (läuft über den Webpack-Dev-Server) nimmt konsistent 60% CPU-Leistung auf. Aus dem CPU-Profil, sieht wie Anruf _proc_listpidspath ist der Schuldige. Irgendwelche Hinweise darauf, was diese Funktion erfordert, und wie Sie herausfinden können, welche Knotenbibliothek dies aufruft.hohe CPU-Auslastung einer Knoten-App

danke.

Siehe das Profil unten.

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 

Edit:

ich dies isolieren könnte, wenn es passiert. Ich habe gestern angefangen, yarn zu verwenden. Nun, wenn ich meine node_modules entfernen und npm -i laufen alle deps durch NPM-Client zu installieren, ich sehe die Dateianzahl innerhalb node_modules als

node_modules ❯❯❯ find . -print | wc -l                                 master 
    43058 

Wenn ich entfernen, node_modules und lief ~/.yarn/bin/yarn.js, dann

node_modules ❯❯❯ find . -print | wc -l                                 ⏎ master 
    32138 

Also, es gibt einen Unterschied in den Dateien, die von beiden CLI installiert werden, und Garn installiert weniger. Aber die CPU mit Garn ist 80% im Leerlauf (Webpack-Server im Watch-Modus) und 1% mit npm. !!

+0

Welche Plattform laufen Sie? – jlengrand

+1

Von [dies] (http://opensource.apple.com//source/Libc/Libc-498/darwin/proc_listpidspath.c) Ich bekomme die Idee, dass Sie 'fs.watch()' oder verwenden können 'fs.watchFile()'. – robertklep

+1

Bitte beachten Sie die Änderungen. Es ist wahrscheinlich Webpack Watch, und das Betriebssystem ist Mac OSX. – bsr

Antwort