Addressing JavaScript JIT Engines Performance Quirks: A Crowdsourced Adaptive Compiler

JavaScript has long outpaced its original target applications, being used not only for coding complex web clients, but also web servers, game development and even desktop applications. The most appealing advantage of moving applications to JavaScript is i

  • PDF / 521,037 Bytes
  • 20 Pages / 439.363 x 666.131 pts Page_size
  • 47 Downloads / 203 Views

DOWNLOAD

REPORT


University of Campinas, Brazil {auler,edson}@ic.unicamp.br 2 Microsoft Research, Redmond, WA, USA {jhalleux,micmo,nikolait}@microsoft.com

Abstract. JavaScript has long outpaced its original target applications, being used not only for coding complex web clients, but also web servers, game development and even desktop applications. The most appealing advantage of moving applications to JavaScript is its capability to run the same code in a large number of different devices. It is not surprising that many compilers target JavaScript as an intermediate language. However, writing optimizations and analyses passes for a compiler that emits JavaScript is challenging: a long time spent in optimizing the code in a certain way can be excellent for some browsers, but a futile effort for others. For example, we show that applying JavaScript code optimizations in a tablet with Windows 8 and Internet Explorer 11 increased performance by, on average, 5 times, while running in a desktop with Windows 7 and Firefox decreased performance by 20%. Such a scenario demands a radical new solution for the traditional compiler optimization flow. This paper proposes collecting web clients performance data to build a crowdsourced compiler flag suggestion system in the cloud that helps the compiler perform the appropriate optimizations for each client platform. Since this information comes from crowdsourcing rather than manual investigations, fruitless or harmful optimizations are automatically discarded. Our approach is based on live measurements done while clients use the application on real platforms, proposing a new paradigm on how optimizations are tested. Keywords: Adaptive compilation, JavaScript engines, just-in-time compilation.

1

Introduction

JavaScript started as a simple non-professional scripting language in 1995 to support small-scale client-side logic in the earliest versions of the Netscape Navigator web browser. By now the language has become so pervasive that it invaded even non-web domains previously reserved for classic programming languages. With the availability of high performing virtual machines like Node.js [28] and efficient Just-in-Time (JIT) compilation technology, not only are complex web A. Cohen (Ed.): CC 2014, LNCS 8409, pp. 218–237, 2014. c Springer-Verlag Berlin Heidelberg 2014 

Addressing JavaScript JIT Engines Performance Quirks

219

applications moving its logic to client-side JavaScript, but server applications are also being coded in JavaScript as much of the server-side programming logic fits nicely with JavaScript closures. Overall, JavaScript’s popularity made the language common for coding web clients, web servers, game development and even desktop applications [1]. The most appealing advantage of moving applications to JavaScript is its capability to run the same code in a large number of different devices. This was a major factor for the design of TouchDevelop [29], a modern, device independent browser-based programming language and development environment. TouchDevelop offers a platform for users t