4 ms·
I am working on interpreters and compilers for dynamic languages for my PHD. I'm spitballing the numbers a bit but in my experience the exact speedups vary a lo
by ufo 8y ago
I am working on interpreters and compilers for dynamic languages for my PHD. I'm spitballing the numbers a bit but in my experience the exact speedups vary a lot depending on the particular choice of language and benchmark. I have more experience with Lua, for which I wrote a bytecode-to-C compiler once (gcc can do wonderful things if you throw some C code at it...). Most of my benchmarks got a speedup between 2x to 3x but some of them got up to 9x.
BTW, "number crunchy" benchmarks like GCD are the best case scenario for ahead of time compilation because the interpretation overhead for them is very high. The interpreter is running lots of bytecodes, and each bytecode is only doing one or two machine instructions of actual work. Did you happen to compare your results against a C implementation of the program (or PyPy JIT)? My experience with Lua was that despite the high speedups compared to the interpreter, the numeric benchmarks still ran much slower than something an AOT compiler for a statically-typed language (or a speculative JIT for a dynamic one) can produce. There is a high cost to the dynamic typing, as variables have to be stored in the interpreter stack instead of in machine registers, and the diamond-shaped control flow gets in the way of optimizations, etc. Getting a 10x speedup in a benchmark that runs 100x slower than C might mean that there is still a lot of fat left to cut :)