wasmtime icon indicating copy to clipboard operation
wasmtime copied to clipboard

Troubleshooting slow Cranelift compile times

Open tmngo opened this issue 3 years ago • 2 comments
trafficstars

Original Zulip topic

Based on the above Zulip topic, I made this issue and attached the generated CLIF.

I'm using Cranelift as a backend for a language I'm working on. I also have an LLVM backend (via Inkwell). While messing around with some test code, I noticed that for a very large function (10000+ lines), my Cranelift backend takes longer (~4.0s) to generate code than my LLVM backend (~1.5s). Here's my crude test case source, which continues on for about 10000 lines.

Screenshot 2022-11-09 032154

define_function main: 3.4641968s
======== ========  ==================================
   Total     Self  Pass
-------- --------  ----------------------------------
   1.090    0.696  Verify Cranelift IR
   0.314    0.314  Verify CPU flags
   6.916    0.161  Compilation passes
   0.040    0.040  Control flow graph
   0.060    0.060  Dominator tree
   0.000    0.000  Remove unreachable blocks
   0.009    0.009  Remove constant phi-nodes
   0.466    0.466  VCode lowering
   0.225    0.225  VCode emission
   0.001    0.001  VCode emission finalization
   1.487    1.487  Register allocation
======== ========  ==================================

clif.zip

tmngo avatar Nov 09 '22 19:11 tmngo

@tmngo we can definitely look into this; we have some long-running efforts to find ways to speed things up. One quick thing I would note though is that you have the verifier enabled. You can disable that (the Cranelift setting is enable_verifier) for a bit of a speedup.

cfallin avatar Nov 09 '22 19:11 cfallin

Thanks! That definitely closes the gap a decent amount.

tmngo avatar Nov 09 '22 19:11 tmngo