In this paper, we present a user-collaborative optimization system for Python program execution. The goal of our work is to target an intermediary point in the runtime design space between interpreter-based runtimes and dynamic compilation systems for dynamic scripting languages -- to improve the performance of their programs without increasing the software complexity and memory footprint of their runtimes. Our solution is a comprehensive framework that implements a remote application evolution model: the system collects and aggregates feedback (sample-based, across-input profiles) from the use of a particular application "in-the-wild". We then use these profiles remotely to specialize the application statically and return the optimized application to user as part of a software update. The optimized code can execute using any interpreter system (instrumented or unmodified).
To enable this approach, we exploit new information that we observe about the behavior of dynamic language programs: (i) the types used at particular program points are similar across different program inputs, and (ii) the polymorphism of call site targets can be reduced if we consider calling contexts. The combination of these two insights enables us to collect a small amount of calling-context-aware type information from multiple users of a program, and then to use this information to guide aggressive type-specialization of the program remotely (using a combination of automatic and by-hand translation in our prototype). We extensively evaluate our approach using community benchmarks and real applications. We find that our system results in significantly better program performance than interpretation and performance similar to that of the popular PyPy dynamic compilation system, while retaining the benefits of interpretation (simplicity of implementation and small memory footprint).