Richard> I don't think a 3% speedup is worth those drawbacks.
Richard> Or even a 10% speedup.
Richard> A really big speedup would justify the costs.
Tom> It is 3x, not 3%.
Mic drop. Richard> I don't think a 3% speedup is worth those drawbacks.
Richard> Or even a 10% speedup.
Richard> A really big speedup would justify the costs.
Tom> It is 3x, not 3%.
Mic drop.In some simple benchmarks, it is about 3x faster than the bytecode interpreter.
I'm always skeptical of statements of these, because workloads vary so much.
JITs seem to do well for numerical benchmarks, e.g. summing a list of numbers or the mandelbrot fractal.
They seem to do worse with string-based workloads, because the bottleneck is in memory allocations, and I have yet to see a JIT that does anything about that (i.e. analyzing code to reduce allocations).
I imagine that ELisp is used mostly for string workloads and not numeric workloads. So I won't be surprised if the 3x number doesn't hold up. I'm interested in hearing more details and happy be to be corrected.
You mean you've never seen a JIT that does anything about memory allocations for ELISP? Or do you mean you've never seen a JIT do anything at all about memory allocations?
Because removing memory allocations through escape analysis and scalar replacement is a key feature of any sophisticated JIT, and there are definitely many JITs which do this.
The JIT for Ruby I work on will effectively remove the allocation of string objects.
I have been reading some papers on JITs and I don't see escape analysis mentioned that often. In the PyPy paper (which is over a decade old) they mention it as future work.
Still, I actually tried PyPy on a string-based workload and it was slower than CPython and used more memory. I don't know why but that contributes to my feeling that JITs are bad for string-based workloads.
I'm interested in seeing any pointers to benchmarks that show the improvements resulting from escape analysis in JITs. I haven't seen anything like that and I've done a decent amount of research.
A cursory look at this blog post makes me think it's not super straightforward:
https://v8project.blogspot.com/2017/09/disabling-escape-anal...
That post is less than a year old! i.e. the fact that v8 has been around for 10+ years and they're still updating escape analysis makes me wonder what the issue with it is. Is it hard to implement or does it not produce that much speedup? I appreciate any pointers.
If you've done a decent amount of research in the field of JITs and you aren't aware of what escape analysis achieves in practice then I'm very surprised.
http://www.ssw.uni-linz.ac.at/Research/Papers/Stadler14/Stad...
That paper is relatively recent, so you can follow the chain of papers from its references.
Now that I'm implementing a interpreter for a relational language and from what I know for why python is slow:
https://jakevdp.github.io/blog/2014/05/09/why-python-is-slow...
And also:
https://speakerdeck.com/alex/why-python-ruby-and-javascript-...
Is challenging to be dynamic and also fast. So, you need to design the language/runtime with performance in mind, or at least, to minimize what could be very slow (that is what I'm triying).
Most JITs do this. LuaJIT does allocation sinking of tables, strings, and even C-FFI structs. HotSpot does escape analysis of everything. IIRC Graal can even do partial escape analysis (allocate the object on the stack and then copy it to the heap if it escapes on one code path). I imagine the major JavaScript engines are similar. It's a well-known performance optimization.
From what I gather, it's a lot more important in PyPy because integers and floats are boxed!
https://www.usenix.org/legacy/events/vee05/full_papers/p111-...