Profiling CPython at Instagram (2017)
instagram-engineering.com
instagram-engineering.com
> But Shapiro may not be aware that the Python core developers have often preferred simpler, more understandable code that is easier to read and follow, over more complex algorithms and data structures in the interpreter. Some performance may well have been sacrificed for readability.
> Mark Shannon said that Python 3.7 has added a feature that should provide a similar boost as the method-lookup caching used in the experiment. Shapiro said he had looked at those changes but still believed his proposed mechanism would provide more benefit. Attribute lookup still requires five lookups in CPython, while it is only one lookup in the experimental version. Shannon did not sound entirely convinced of that, however.
This observation and the accompanying graph are, I think, the "generational hypothesis" equivalent to static types.
The generational hypothesis says most objects are either very short-lived or long-lived and modern generation GCs very effectively optimize for that fact.
A particularly pragmatic way to look at static types is that they optimize for monomorphic calls at the expense of polymorphic calls. For the latter, they require you to manually define interfaces, virtual methods, or some other explicit dynamism. In return, monomorphic calls are much faster.
The 85% number is an indication that that's a good optimization, as long as the other 15% aren't too hard to handle in your statically-typed language.
The GC optimization, well, that'll probably be left up to other interpreters.
[0] "Mark Shannon said that Python 3.7 has added a feature that should provide a similar boost as the method-lookup caching used in the experiment. Shapiro said he had looked at those changes but still believed his proposed mechanism would provide more benefit. Attribute lookup still requires five lookups in CPython, while it is only one lookup in the experimental version. Shannon did not sound entirely convinced of that, however." https://lwn.net/Articles/754163/
Did anybody try anything in these line of work?
Dalvik also uses a register-based bytecode. The early versions of Android needed a more efficient interpreter. Dan Bornstein's talk: https://www.youtube.com/watch?v=ptjedOZEXPM
A classic paper on Register vs Stack VMs: https://www.usenix.org/legacy/events/vee05/full_papers/p153-...
The CS-Fundamentals that underscore (Python, Perl, PRCE, and Java regexes) are the same. So this longer article may help: https://www.javaworld.com/article/2077757/core-java/optimizi... as while the syntax of the regex may change, the side effects and performance implications of the individual operators will not.
[1] https://wiki.python.org/moin/PythonSpeed/PerformanceTips#Dat...
https://www.paypal-engineering.com/2014/12/10/10-myths-of-en...