That's interesting data. Do you only run that function once? In that case, it can indeed happen that TurboFan code is not ready when you enter the function, so you end up running Liftoff exclusively. This should not depend on that one constant though.
Also, being 200x slower would be an extreme case for Liftoff, and it would still be interesting to compare the generated code and check for optimization potential. On Wed, Apr 8, 2020 at 11:46 AM Immanuel Haffner <[email protected]> wrote: > Ok, I have added the flags Clemens suggested and got the disassembly that > TurboFan produced. I will append them for both < 0 and < 1 below. However, > the slowdown for < 0 disappeared! Maybe this is related to liftoff? I will > recompile V8 with liftoff enabled and rerun the experiment once more. > > Disassembly for < 0 on AMD Ryzen Threadripper 1900X: > --- WebAssembly code --- > index: 0 > kind: wasm function > compiler: TurboFan > Body (size = 192 = 178 + 14 padding) > Instructions (size = 156) > 0x39bc600062c0 0 55 push rbp > 0x39bc600062c1 1 4889e5 REX.W movq rbp,rsp > 0x39bc600062c4 4 6a0a push 0xa > 0x39bc600062c6 6 56 push rsi > 0x39bc600062c7 7 4883ec28 REX.W subq rsp,0x28 > 0x39bc600062cb b 488b5e4f REX.W movq rbx,[rsi+0x4f] > 0x39bc600062cf f 488b560b REX.W movq rdx,[rsi+0xb] > 0x39bc600062d3 13 488b4e13 REX.W movq rcx,[rsi+0x13] > 0x39bc600062d7 17 4883e903 REX.W subq rcx,0x3 > 0x39bc600062db 1b 33ff xorl rdi,rdi > 0x39bc600062dd 1d 4c8bc7 REX.W movq r8,rdi > 0x39bc600062e0 20 4c8b4e23 REX.W movq r9,[rsi+0x23] > 0x39bc600062e4 24 493b21 REX.W cmpq rsp,[r9] > 0x39bc600062e7 27 0f8633000000 jna 0x39bc60006320 <+0x60> > 0x39bc600062ed 2d 446bcf2c imull r9,rdi,0x2c > 0x39bc600062f1 31 448b5b0c movl r11,[rbx+0xc] > 0x39bc600062f5 35 4503cb addl r9,r11 > 0x39bc600062f8 38 4c3bc9 REX.W cmpq r9,rcx > 0x39bc600062fb 3b 0f8352000000 jnc 0x39bc60006353 <+0x93> > 0x39bc60006301 41 42833c0a00 cmpl [rdx+r9*1],0x0 > 0x39bc60006306 46 0f8d04000000 jge 0x39bc60006310 <+0x50> > 0x39bc6000630c 4c 4183c001 addl r8,0x1 > 0x39bc60006310 50 83c701 addl rdi,0x1 > 0x39bc60006313 53 397b08 cmpl [rbx+0x8],rdi > 0x39bc60006316 56 77c8 ja 0x39bc600062e0 <+0x20> > 0x39bc60006318 58 498bc0 REX.W movq rax,r8 > 0x39bc6000631b 5b 488be5 REX.W movq rsp,rbp > 0x39bc6000631e 5e 5d pop rbp > 0x39bc6000631f 5f c3 retl > 0x39bc60006320 60 48895de8 REX.W movq [rbp-0x18],rbx > 0x39bc60006324 64 48897de0 REX.W movq [rbp-0x20],rdi > 0x39bc60006328 68 4c8945d8 REX.W movq [rbp-0x28],r8 > 0x39bc6000632c 6c 488955d0 REX.W movq [rbp-0x30],rdx > 0x39bc60006330 70 48894dc8 REX.W movq [rbp-0x38],rcx > 0x39bc60006334 74 e887feffff call 0x39bc600061c0 ;; wasm stub: > WasmStackGuard > 0x39bc60006339 79 488b5de8 REX.W movq rbx,[rbp-0x18] > 0x39bc6000633d 7d 488b7de0 REX.W movq rdi,[rbp-0x20] > 0x39bc60006341 81 4c8b45d8 REX.W movq r8,[rbp-0x28] > 0x39bc60006345 85 488b55d0 REX.W movq rdx,[rbp-0x30] > 0x39bc60006349 89 488b4dc8 REX.W movq rcx,[rbp-0x38] > 0x39bc6000634d 8d 488b75f0 REX.W movq rsi,[rbp-0x10] > 0x39bc60006351 91 eb9a jmp 0x39bc600062ed <+0x2d> > 0x39bc60006353 93 e8f8fcffff call 0x39bc60006050 ;; wasm stub: > ThrowWasmTrapMemOutOfBounds > 0x39bc60006358 98 90 nop > 0x39bc60006359 99 0f1f00 nop > > Source positions: > pc offset position > 60 13 > 93 23 > > Safepoints (size = 22) > 0x39bd600062bfffffffff 000000000 (sp -> fp) > > RelocInfo (size = 4) > 0x39bc60006335 wasm stub call > 0x39bc60006354 wasm stub call > > --- End code --- > > Disassembly for < 1 on AMD Ryzen Threadripper 1900X: > --- WebAssembly code --- > index: 0 > kind: wasm function > compiler: TurboFan > Body (size = 192 = 178 + 14 padding) > Instructions (size = 156) > 0x18d7ed9202c0 0 55 push rbp > 0x18d7ed9202c1 1 4889e5 REX.W movq rbp,rsp > 0x18d7ed9202c4 4 6a0a push 0xa > 0x18d7ed9202c6 6 56 push rsi > 0x18d7ed9202c7 7 4883ec28 REX.W subq rsp,0x28 > 0x18d7ed9202cb b 488b5e4f REX.W movq rbx,[rsi+0x4f] > 0x18d7ed9202cf f 488b560b REX.W movq rdx,[rsi+0xb] > 0x18d7ed9202d3 13 488b4e13 REX.W movq rcx,[rsi+0x13] > 0x18d7ed9202d7 17 4883e903 REX.W subq rcx,0x3 > 0x18d7ed9202db 1b 33ff xorl rdi,rdi > 0x18d7ed9202dd 1d 4c8bc7 REX.W movq r8,rdi > 0x18d7ed9202e0 20 4c8b4e23 REX.W movq r9,[rsi+0x23] > 0x18d7ed9202e4 24 493b21 REX.W cmpq rsp,[r9] > 0x18d7ed9202e7 27 0f8633000000 jna 0x18d7ed920320 <+0x60> > 0x18d7ed9202ed 2d 446bcf2c imull r9,rdi,0x2c > 0x18d7ed9202f1 31 448b5b0c movl r11,[rbx+0xc] > 0x18d7ed9202f5 35 4503cb addl r9,r11 > 0x18d7ed9202f8 38 4c3bc9 REX.W cmpq r9,rcx > 0x18d7ed9202fb 3b 0f8352000000 jnc 0x18d7ed920353 <+0x93> > 0x18d7ed920301 41 42833c0a01 cmpl [rdx+r9*1],0x1 > 0x18d7ed920306 46 0f8d04000000 jge 0x18d7ed920310 <+0x50> > 0x18d7ed92030c 4c 4183c001 addl r8,0x1 > 0x18d7ed920310 50 83c701 addl rdi,0x1 > 0x18d7ed920313 53 397b08 cmpl [rbx+0x8],rdi > 0x18d7ed920316 56 77c8 ja 0x18d7ed9202e0 <+0x20> > 0x18d7ed920318 58 498bc0 REX.W movq rax,r8 > 0x18d7ed92031b 5b 488be5 REX.W movq rsp,rbp > 0x18d7ed92031e 5e 5d pop rbp > 0x18d7ed92031f 5f c3 retl > 0x18d7ed920320 60 48895de8 REX.W movq [rbp-0x18],rbx > 0x18d7ed920324 64 48897de0 REX.W movq [rbp-0x20],rdi > 0x18d7ed920328 68 4c8945d8 REX.W movq [rbp-0x28],r8 > 0x18d7ed92032c 6c 488955d0 REX.W movq [rbp-0x30],rdx > 0x18d7ed920330 70 48894dc8 REX.W movq [rbp-0x38],rcx > 0x18d7ed920334 74 e887feffff call 0x18d7ed9201c0 ;; wasm stub: > WasmStackGuard > 0x18d7ed920339 79 488b5de8 REX.W movq rbx,[rbp-0x18] > 0x18d7ed92033d 7d 488b7de0 REX.W movq rdi,[rbp-0x20] > 0x18d7ed920341 81 4c8b45d8 REX.W movq r8,[rbp-0x28] > 0x18d7ed920345 85 488b55d0 REX.W movq rdx,[rbp-0x30] > 0x18d7ed920349 89 488b4dc8 REX.W movq rcx,[rbp-0x38] > 0x18d7ed92034d 8d 488b75f0 REX.W movq rsi,[rbp-0x10] > 0x18d7ed920351 91 eb9a jmp 0x18d7ed9202ed <+0x2d> > 0x18d7ed920353 93 e8f8fcffff call 0x18d7ed920050 ;; wasm stub: > ThrowWasmTrapMemOutOfBounds > 0x18d7ed920358 98 90 nop > 0x18d7ed920359 99 0f1f00 nop > > Source positions: > pc offset position > 60 13 > 93 23 > > Safepoints (size = 22) > 0x18d8ed9202bfffffffff 000000000 (sp -> fp) > > RelocInfo (size = 4) > 0x18d7ed920335 wasm stub call > 0x18d7ed920354 wasm stub call > > --- End code --- > > If you do a diff and ignore the addresses, you can see that the only > difference is the cmpl [rdx+r9*1],0x1. > > I have two configurations of V8 on the server now, one default release > build and one release build with the flags --print-wasm-code --predictable > --no-liftoff. Running the experiment in the former has 2000 ms running > time while running the experiment in the latter has running time 11 ms. > > -- > -- > 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]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-dev/9f1cbe84-fb3c-40c6-af82-7bf536684e79%40googlegroups.com > <https://groups.google.com/d/msgid/v8-dev/9f1cbe84-fb3c-40c6-af82-7bf536684e79%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Clemens Backes Software Engineer [email protected] Google Germany GmbH Erika-Mann-Straße 33 80636 München Geschäftsführer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde. This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person. -- -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAGO%3DqhCS_4Z8xRX8ZjWtdPjE284rOpQqdD3EhRMfDiuMqY_ftA%40mail.gmail.com.
