98 points · by ingve · 9y ago · 18 comments
The famous result is the old computed goto vs switch argument, which basically comes down to switch adds bounds-checking overhead. He didn't get that. Most commenters neither. He also cemented the poor wording "threaded interpreter" and "indirect branching" for different concepts. It's also a totally unimportant feature of making interpreters fast.
Indirect call overhead is significant and measurable. Jit compilers made that obsolete.
He didn't get the case against perl. perl has a huge op and data overhead, as is way too dynamic. But the dispatch loop is better than the others, as perl always returns the pointer to the next op already. There's no dispatch.
Much better interpreter optimization papers came later with lua, reiterating old lisp results. Note: not luajit. lua already had a perfect interpreter loop. lua uses the lisp architecture of small tagged dynamic data, plus a tiny opset, efficiently stored in a single word, with 2-3 arguments. python with its linearizing cfg optimizer tried to mimic it a bit, but is still too slow. Many one-word primitives allow fast stack allocation and updates, and one-word ops allow fast icache throughput.
Can you point to some of those papers?
With jit added, luajit is perfect. This is a completely different beast. Also the self/strongtalk derived jits of course: hotspot and v8.
This provides a reasonable tl;dr, with nice ASCII figures:
http://web.archive.org/web/20170102051538/http://article.gma...
If anyone's curious about tales from the battlefield, highly recommend Cliff Click's talks (any of them) [1]
Sadly, the archive.org links on their website aren't working :(
I've just sent them a tweet, maybe they will fix it
This led us down a path of also using an interpreter within our own regex engine (Hyperscan) - not for individual engines like NFA/DFA/literal match but for the overall orchestration layer. It's been quite an improvement of code cleanliness and generally has been either performance-neutral or even good. When you replace a great big ugly clagged "if this rare thing happens, go do this code, or else if this happens, go do this other things, then ..." with an interpreter you can get nice performance benefits in the common case - even though there are not branch misses in the "giant clagged pile of code" anti-pattern.
I think even the Lua Paper had a bit about that.
[edit: get his name right. you'd think i'd know it, since he rubs my nose into some bugs I wrote 30+ years ago every time we meet. hi, darek! :-)]