3 ms·
I don't think the world is quite so bad. x86 processors solve this by speculating about what's going on. If you suddenly run into a 1976-era operation, everyth
by blagie 5y ago
I don't think the world is quite so bad.
x86 processors solve this by speculating about what's going on. If you suddenly run into a 1976-era operation, everything slows down dramatically for a bit (but still goes faster than an 8086). If you have a branch or cache miss, things slow down a little bit.
One has a few possibilities:
- A static analysis /proves/ something. print is print. You optimize a lot.
- A static analysis /suggests/ something. print is print, unless redefined in an eval. You just need to go into a slow path in operations like `eval`, so if print is modified, you invalidate the static analysis.
- A static or dynamic analysis suggests something probabilistically. You can make the fast path fast, and the slow path eventually work. If print isn't print, you raise an internal exception, do some recovery, and get back to it.
I'm also okay with this analysis being run in prod and not in dev.
As a footnote, JITs, especially in Java, show that this kind of analysis can be pretty fast. You don't need it to work 100% of the time. The case of a variable being redefined in a dozen places, you just ignore. The case where I call a function from three places which increments an integer each time, I can find with hardly any overhead at all. The latter tends to be where most of the bottlenecks are.