On The Death of JIT Compilation

I remember studying Java early in my education and first learning about the wonders of just-in-time compilation (JIT). Somehow, a super-intelligent (no, not the meaningless AI hype super-intelligence that the White House insists on using) engine is able to analyze my program while it’s running and manage to execute it with performance on the order of specialized, non-portable, natively-compiled code, sometimes with superior performance. As a young engineering student at the time (and don’t get me started on how ‘engineering’ has become a meaningless term, too), I was more than happy to accept this magic. But now, as a senior software engineer and security researcher, I understand that all complexity comes with a cost, and so the software industry has shifted decades later to a dramatic rejection of this incredible technology. Indeed, nothing in life is free, and it turns out some of those promises were indeed tall tales and too good to be true.

The Promise of JIT

For the user and the developer, the JIT appears to promise more and better, almost for free. We get all the benefits of specializing our code to the specific target without loss of generality: portability, with all the flexibility and introspection of a powerful runtime. This was a magnificent upsell for the hottest programming languages at the time. Java, for example, was proffered on the premises of:

  • Write Once, Run Anywhere
  • Memory Safety and Automatic Garbage Collection
  • World Wide Web Modernization
  • Familiarity for C/C++ Developers

The ethos of letting the runtime do the heavy lifting promised to solve the era’s biggest bottlenecks–compute power and developer bandwidth–so teams could get products out the door and into users’ hands before being left behind by a more aggressive competitor. Vendors prioritized speed to market above all else, a mindset that eventually gave rise to unified stacks like full-stack Java and JavaScript. That philosophy proved ideal for massive web applications and the mobile boom that followed in the mid to late 2000s, where success depended on reaching users wherever they were, moving fast (break things!), and capturing the market early to cement a foothold in the new Internet era. Go big, get there first, or don’t bother.

This explosive development ethic was always fundamentally unsustainable. Most new mobile and web business failed or consolidated until only a few giants remained. Explosive growth is replaced by last-mile competition, the final 10% of the application details and the manner in which the business operates becoming the primary differentiating factors.

A Maturing Industry

Full-stack development still exists, but supporting the native tooling available in the target environment matters. For example, Facebook (now Meta) redesigned their app from portable web-based to be more native, using Swift/Objective-C on iOS and Kotlin/Java on Android with separate, targeted development teams. The once-popular Airbnb app migrated from React Native to a similar platform-targeted development model, another rejection of the one-size-fits-all, full-stack growth play. Micosoft Teams and 1Password moved from Electron apps to designs favoring the local technologies wherever possible. The pattern of starting with an “all-in-one, ship everywhere fast” stack and later breaking it apart into specialized, platform-targeted technologies has played out repeatedly across desktop apps, mobile clients, and backend infrastructure. I highlight mobile specifically because that’s what most users will be familiar with, but this happened in the backend area as well such as with Dropbox dropping Python for compiled Rust and Go services.

On the technology side, we observe a related situation. Python introduced a JIT with real performance gains, and then development was halted abruptly because of maintenance and complexity concerns. A now-rescinded proposal for continued development attempted to define responsibilities and integration between the massive JIT framework and the rest of the CPython application, and now the technology appears to be slated for removal. PHP has a mature JIT that almost nobody uses because PHP CPU performance is unimportant in most real-world use cases.

Hidden complexity connects these industry developments. On the surface, using one technology stack–or one massive JIT engine to solve all performance problems–looks deceptively simple. Yet it achieves that simplicity by sweeping real trade-offs under the rug, relying on oversimplifications that treat fundamentally different targets as equal or promise something for nothing. A JIT compiler, for instance, consumes valuable system resources at runtime to optimize a program every single time it runs. Worse, dynamic code generation remains such a consistent source of serious security vulnerabilities that iOS Lockdown Mode disables the feature altogether. JIT is a great solution to reducing the cost of the portability problem if that’s what a project needs, at the price of some of its real-world performance through a complex and costly runtime. Increasingly we’re seeing that this trade if is not appropriate outside of an explosive growth phase.

The one notable exception is JavaScript. By its sheer economic relevance, squeezing out every last drop of performance to execute the common language of the browsable Internet matters immensely. Legacy code will exist online practically forever, so full migration to a general web standard of a ‘better’ language that does not require the large investment of runtime JIT (see: WebAssembly) is unlikely. JavaScript isn’t going away anytime soon, so even for modest overall improvements, a large and complex runtime is justified by our inability to adapt quickly to new languages and runtimes on the open Internet.

What JIT Really Costs

For a fully runtime JIT solution, we must initialize a large runtime before we can even begin to examine the real application code. Java is famous for its terrible startup performance, which Android worked around aggressively for years through its Zygote forking process design and class pre-loading until the JIT was largely abandoned for cloud-based ahead of time compilation infrastructure. JIT contains a structural flaw baked into any architecture that defers compilation until the user is already waiting. The application needs to perform right now! Immediately!

Once the runtime is ready, the application code must carry the weight of the runtime profiling and compiling software simultaneously. This costs not only extra memory to store different versions of the same logic, but on mobile in particular, battery life suffers and it suffers every time the code must be re-compiled, and again every time the application runs.

This weight is extreme enough to mitigate the benefits of the JIT outside of mirco benchmarks. Microsoft’s Browser Vulnerability Research team disabled V8’s JIT compiler in Edge to test a hardened browsing mode, and in 2021 found that startup times actually improved and most users don’t notice the modest peak performance drop. Further, the prevalence of lightweight JavaScript interpreters also suggests that good solutions exist in the same space without making big runtime sacrifices and hauling a compiler along with the application. You may find JIT disabled in a future browser release if large, CPU-intensive JavaScript apps become less common.

Concluding Remarks

When we can re-architect, we should. Across the industry, teams are moving away from sweeping solutions that promise everything and toward focused choices with clear goals. Today, JIT compilation rarely offers a worthwhile trade-off: unless you are bound to the web via JavaScript or running a platform specifically engineered for adaptive runtime performance through a rich intermediate representation like Java or .NET, JIT sacrifices memory, CPU, and security for the portability we can absolutely achieve through better means.

Look across the industry and the pattern is unmistakable: maturing software engineering means recognizing that both complex runtimes (and JIT runtimes) and uniform full-stack designs were compromises born of their era. Even if JIT technology was and still is, academically and in specific niches, really super cool.

Previous post:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.