Google Groups

Re: [node-dev] Speed impact of node::MakeCallback


Jann Horn Apr 7, 2012 4:06 PM
Posted in group: nodejs-dev
Am Sonntag, den 08.04.2012, 00:59 +0200 schrieb Ben Noordhuis:
> On Sun, Apr 8, 2012 at 00:38, Jann Horn <jann...@googlemail.com> wrote:
> > Hello,
> > I've been using a little ad-filtering proxy I built using node for some
> > time now, and today I had a look at its CPU usage while flash was
> > prefetching a very large youtube video. Well, it was relatively high, I
> > think, but the only thing it should be doing at that time is using
> > the .pipe() method to pipe from one HTTP stream to another one.
> >
> > Well, I was surprised to see that node was wasting ~2.5% of its CPU
> > usage on v8::String::New calls in node::MakeCallback, and that
> > node::MakeCallback in total has a CPU overhead that amounts to ~7% of
> > the total CPU time node uses in this case. Shouldn't it at least be
> > possible to cache the symbol string? And couldn't node maybe also avoid
> > calling v8::Object::Get each time it wants to call into userland (~3.6%
> > )?
> >
> > Are these things right or did I make some huge mistake? If they are
> > right, would it be possible to make this stuff a bit faster? Reducing
> > the CPU usage by 5% seems like a relatively big speed improvement to me.
> >
> > Node version: 0.6.14
> >
> > Call graph centered on MakeCallback:
> > http://thejh.github.com/callgraph.png
> >
> > Raw callgrind output:
> > http://thejh.github.com/callgrind.out.19701
>
> Yes, it's a known issue and something we'll address in v0.8, probably
> by scrapping MakeCallback() and moving back to Persistent<T> handles.

Wasn't MakeCallback() also supposed to handle the domains stuff? And
don't many C++ modules use that?