On Fri, Sep 21, 2012 at 12:02 PM, Robert Chris Bang Larsen <[email protected]> wrote: > Hi all > > I am reimplementing a Java based chatserver into a Node.js based one with > the Socket.io library. That proved more difficult than I had thought. > > The Java server never generate any real load (around 3-10%...mostly 3%) but > the Node.js process quickly generates 100% on that one cpu. > > I ran node with --profile and ran the result through nprof. The result can > be seen here: http://pastebin.com/UNUCHtU0 > > Here is a summary: > [Shared libraries]: > ticks total nonlib name > 405876 97.1% 0.0% /lib64/libc-2.12.so > 7990 1.9% 0.0% /opt/node-v0.6.19/bin/node > 800 0.2% 0.0% /lib64/libpthread-2.12.so > 28 0.0% 0.0% /lib64/libm-2.12.so > ..... > [JavaScript]: > ticks total nonlib name > 100 0.0% 2.9% KeyedLoadIC: A keyed load IC from the snapshot > 77 0.0% 2.2% LazyCompile: *EventEmitter.emit events.js:40 > 70 0.0% 2.0% Stub: CEntryStub > 69 0.0% 2.0% LazyCompile: *exports.active timers.js:143 > 54 0.0% 1.6% LazyCompile: *onread net.js:347 > ... > > So, far the most time is spent in libc. But how can I tell what it is doing > there and why it is generating that kind of load on the cpu? > > Best regards, > Robert
Ticks are wall clock time and most of it is apparently spent in libc. There's a couple of things you can do: 1. Run `time node app.js`. It prints out user vs. kernel time statistics. 2. Trace your application with `strace -c`, it prints out system call statistics. 3. Run `valgrind --tool=callgrind node app.js` and post-process the log with `callgrind_annotate --auto=yes`. It will tell you where node spends its CPU cycles. callgrind is slow but accurate down to the single cycle. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
