Improving a web hosting service
Speeding up PHP & Javascript runtimes.
Last Significant Update: |
2024-07-05 |
Status: |
Draft |
Comments to: |
ⲙⲉⲓ (Maat) is an SRE working for large webhosting company hosting millions of websites. Maat’s boss, Ra, has commanded her to make the site’s operation more ‘virtuous’.
The site runs on PHP and Javascript. Maat figures that she needs to improve the runtimes for these two languages, but isn’t sure where to start.
Maat tries conventional ‘tick’-based and hardware counter-based profiling first, but she quickly discovers that conventional profiling does not go very far when dealing with interpreted languages.
Maat’s colleague Thoth recommends that she look at the Mensurae toolkit as an alternative. Maat discovers that this toolkit has been designed from the start for applications to measure their own behavior on hardware.[1]
Maat starts by adding starts by instrumenting the PHP and Javascript runtimes using Mensurae’s APIs for self-measurement. She deploys her instrumented runtimes to production, and starts collecting information about the behavior of these language runtimes when running the actual workloads in production.
Maat collects information about instruction counts & cache misses per interpreted ‘opcode’, the behaviour on hardware of JIT’ed code, the hardware behavior of the garbage collectors involved, the behavior of the locks in the code, and so on. She then uses this data to guide performance improvements to these runtimes.
Design Considerations
Self-measurement API
Production Stability
Mensurae’s APIs and other infrastructure (e.g., trace collection) should not cause instability.
Low-overheads
Mensurae’s instrumentation should not introduce significant overheads to production software.
Query Language
Mensurae needs to offer an expressive query language for analyzing its collected data.