fib in "Node's main JS thread" case is a "local" function declaration, V8
compiles recursive call as
t32 LoadContextSlot t5[8]
t39 CallFunction t5 t32 #2 changes[*]
in "threads..." and "separate VM" (which is actually not a separate VM,
name is misleading) case it's a global function and recursive invocation
looks like:
t36 LoadGlobalCell [0x2c37c320b761]
t37 CheckFunction t36 0x1a9cbc67f2a9
t41 CallKnownGlobal o #2 changes[*]
if you look at assembly you'll see that call-known-global is actually much
simpler and direct (and thus faster) than call-function which uses separate
generic stub:
;;; @40: call-known-global.
0x3c5d7c2c30d 109 48bff96d452dc6150000 REX.W movq rdi,0x15c62d456df9
;; object: 0x15c62d456df9 <JS Function fib>
0x3c5d7c2c317 119 4c89e1 REX.W movq rcx,r12
0x3c5d7c2c31a 122 e881ffffff call 0 (0x3c5d7c2c2a0) ;; debug:
position 41
;; code:
OPTIMIZED_FUNCTION
vs.
;;; @52: call-function.
0x1e5a9c3a52fd 125 e85e46f6ff call 0x1e5a9c309960 ;; debug:
position 139
;; code: STUB,
CallFunctionStub, argc = 1
[call function stub is a complicated generic stub that can handle all kinds
of calls]
--
Vyacheslav Egorov
On Thu, Apr 12, 2012 at 7:29 PM, mscdex <[email protected]> wrote:
> On Apr 12, 9:54 am, Tim Caswell <[email protected]> wrote:
> > What makes the main thread so slow in comparison? It's the same v8
> right?
>
> Here's something more interesting:
>
> https://gist.github.com/2369318
>
> Threads_a_gogo JS thread -> 3039 (ms) 298607040
> Node's main JS thread -> 4677 (ms) 298607040
> Ratio: 1.54 times faster than main JS thread
> New, separate VM -> 3065 (ms) 298607040
> Ratio: 1.01 times faster than new VM
>
> --
> 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
>
--
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