<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<br>
This just went by this morning on reddit's /r/programming. It's a
paper that analyzed Python--among a handful of other languages--to
answer the question "are branch predictors still that bad at the big
switch statement approach to interpreters?" Their conclusion: no.<br>
<blockquote>Our simulations [...] show that, as long as the payload
in the bytecode remains limited and do not feature significant
amount of extra indirect branches, then the misprediction rate on
the interpreter can be even become insignificant (less than 0.5
MPKI).<br>
</blockquote>
(MPKI = missed predictions per thousand instructions)<br>
<br>
Their best results were on simulated hardware with state-of-the-art
prediction algorithms ("TAGE" and "ITTAGE"), but they also
demonstrate that branch predictors in real hardware are getting
better quickly. When running the Unladen Swallow test suite on
Python 3.3.2, compiled with USE_COMPUTED_GOTOS turned off, Intel's
Nehalem experienced an average of 12.8 MPKI--but Sandy Bridge drops
that to 3.5 MPKI, and Haswell reduces it further to a mere *1.4*
MPKI. (AFAICT they didn't compare against Python 3.3.2 using
computed gotos, either in terms of MPKI or in overall performance.)<br>
<br>
The paper is here:<br>
<blockquote><a class="moz-txt-link-freetext" href="https://hal.inria.fr/hal-01100647/document">https://hal.inria.fr/hal-01100647/document</a><br>
</blockquote>
<br>
I suppose I wouldn't propose removing the labels-as-values opcode
dispatch code yet. But perhaps that day is in sight!<br>
<br>
<br>
<i>/arry</i><br>
</body>
</html>