Status: Untriaged
Owner: ----

New issue 4353 by [email protected]: Inlining code containing an array literal leads to a performance loss
https://code.google.com/p/v8/issues/detail?id=4353

Version: fc80f29a582b758d14aae864232624ca45e47ddc
OS: Linux
Architecture: IA32

There are two files attached. The only difference is that in the slow one, a one-line function has been manually inlined:

1876c1876
<         for (var t1 = Y.TreeIterator$(this.items._tree); t1.moveNext$0();)
---
for (var t1 = new Y.TreeIterator(this.items._tree, null, [], null); t1.moveNext$0();)

This leads to a surprising performance loss:

$ ~/v8.git/v8/out/ia32.release/d8 fast.js
Iteration.tree.manual(RunTime): 167.78523489932886 us.

$ ~/v8.git/v8/out/ia32.release/d8 slow.js
Iteration.tree.manual(RunTime): 656.1679790026246 us.

I think this is a bug. It suggests that the reverse transformation (manually abstracting an array literal into a helper function) would sometimes be a big optimization.


Details: slow.js deoptimizes but fast.js does not:

$ ~/v8.git/v8/out/ia32.release/d8 --trace-deopt slow.js
[deoptimizing (DEOPT eager): begin 0x57642411 <JS Function dart.TreeIterator.moveNext$0 (SharedFunctionInfo 0x252949e9)> (opt #27) @6, FP to SP delta: 28]
            ;;; deoptimize at 68012: wrong map
reading input frame dart.TreeIterator.moveNext$0 => node=1, args=142, height=3; inputs: 0: 0x57642411 ; (frame function) 0x57642411 <JS Function dart.TreeIterator.moveNext$0 (SharedFunctionInfo 0x252949e9)>
      1: 0x5205ddf9 ; ecx 0x5205ddf9 <a TreeIterator with map 0x3771480d>
      2: 0x57619789 ; [fp - 16] 0x57619789 <FixedArray[17]>
      3: 0x5205d129 ; eax 0x5205d129 <a Node with map 0x37714261>
      4: 0x5205dde1 ; edx 0x5205dde1 <JS Array[0]>
  translating frame dart.TreeIterator.moveNext$0 => node=142, height=8
0xffb7c0e8: [top + 24] <- 0x5205ddf9 ; 0x5205ddf9 <a TreeIterator with map 0x3771480d> (input #1)
    0xffb7c0e4: [top + 20] <- 0x5e72f730 ;  caller's pc
    0xffb7c0e0: [top + 16] <- 0xffb7c0fc ;  caller's fp
0xffb7c0dc: [top + 12] <- 0x57619789 ; context 0x57619789 <FixedArray[17]> (input #2) 0xffb7c0d8: [top + 8] <- 0x57642411 ; function 0x57642411 <JS Function dart.TreeIterator.moveNext$0 (SharedFunctionInfo 0x252949e9)> (input #0) 0xffb7c0d4: [top + 4] <- 0x5205d129 ; 0x5205d129 <a Node with map 0x37714261> (input #3) 0xffb7c0d0: [top + 0] <- 0x5205dde1 ; 0x5205dde1 <JS Array[0]> (input #4) [deoptimizing (eager): end 0x57642411 <JS Function dart.TreeIterator.moveNext$0 (SharedFunctionInfo 0x252949e9)> @6 => node=142, pc=0x5e71bbcc, state=NO_REGISTERS, alignment=no padding, took 0.167 ms]
[removing optimized code for: dart.TreeIterator.moveNext$0]

The profile produced by --prof shows that slow.js is spending a lot of time in Builtin_ArrayPush:

 [C++ entry points]:
   ticks    cpp   total   name
1317 96.1% 64.7% v8::internal::Builtin_ArrayPush(int, v8::internal::Object**, v8::internal::Isolate*) 16 1.2% 0.8% v8::internal::Runtime_DateCurrentTime(int, v8::internal::Object**, v8::internal::Isolate*) 13 0.9% 0.6% v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) 9 0.7% 0.4% v8::internal::Runtime_CompileOptimized(int, v8::internal::Object**, v8::internal::Isolate*) 5 0.4% 0.2% v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*)

presumably because it does not generate inlined code for the array push builtin.



Attachments:
        fast.js  76.2 KB
        slow.js  76.2 KB

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to