Performance Issues and Optimizations in JavaScript: An Empirical Study

As JavaScript is becoming increasingly popular, the performance of JavaScript programs is crucial to ensure the responsiveness and energy-efficiency of thousands of pro- grams. Yet, little is known about performance issues that developers face in practice and they address these issues. This paper presents an empirical study of 98 fixed performance issues from 16 popular client-side and server-side JavaScript projects. We identify eight root causes of issues and show that inefficient usage of APIs is the most prevalent root cause. Furthermore, we find that most is- sues are addressed by optimizations that modify only a few lines of code, without significantly affecting the complexity of the source code. By studying the performance impact of optimizations on several versions of the SpiderMonkey and V8 engines, we find that only 42.68% of all optimizations improve performance consistently across all versions of both engines. Finally, we observe that many optimizations are instances of patterns applicable across projects, as evidenced by 139 previously unknown optimization opportunities that we find based on the patterns identified during the study. The results of the study help application developers to avoid common mistakes, researchers to develop performance-related techniques that address relevant problems, and engine developers to address prevalent bottleneck patterns.

[1]  Manu Sridharan,et al.  DLint: dynamically checking bad coding practices in JavaScript , 2015, ISSTA.

[2]  Ewan D. Tempero,et al.  Subsuming Methods: Finding New Optimisation Opportunities in Object-Oriented Software , 2015, ICPE.

[3]  Arnar Birgisson,et al.  JSFlow: tracking information flow in JavaScript and its APIs , 2014, SAC.

[4]  Peter Thiemann,et al.  Type Analysis for JavaScript , 2009, SAS.

[5]  Donald E. Knuth,et al.  Computer programming as an art , 1974, CACM.

[6]  Koushik Sen,et al.  TypeDevil: Dynamic Type Inconsistency Analysis for JavaScript , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[7]  Benjamin Livshits,et al.  Practical static analysis of JavaScript applications in the presence of frameworks and libraries , 2013, ESEC/FSE 2013.

[8]  Claus Rautenstrauch,et al.  Performance Engineering: State of the Art and Current Trends , 2001 .

[9]  Lori L. Pollock,et al.  SEEDS: a software engineer's energy-optimization decision support framework , 2014, ICSE.

[10]  Ali Mesbah,et al.  An Empirical Study of Client-Side JavaScript Bugs , 2013, 2013 ACM / IEEE International Symposium on Empirical Software Engineering and Measurement.

[11]  Thomas R. Gross,et al.  Performance regression testing of concurrent classes , 2014, ISSTA 2014.

[12]  Frank Tip,et al.  Dynamic determinacy analysis , 2013, PLDI.

[13]  Koushik Sen,et al.  The Good, the Bad, and the Ugly: An Empirical Study of Implicit Type Conversions in JavaScript , 2015, ECOOP.

[14]  Ahmed E. Hassan,et al.  A qualitative study on performance bugs , 2012, 2012 9th IEEE Working Conference on Mining Software Repositories (MSR).

[15]  Karthik Pattabiraman,et al.  JavaScript Errors in the Wild: An Empirical Study , 2011, 2011 IEEE 22nd International Symposium on Software Reliability Engineering.

[16]  Francesco Logozzo,et al.  RATA: Rapid Atomic Type Analysis by Abstract Interpretation - Application to JavaScript Optimization , 2010, CC.

[17]  Michael Pradel,et al.  Poster: Automatically Fixing Real-World JavaScript Performance Bugs , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[18]  Miryung Kim,et al.  Systematic editing: generating program transformations from an example , 2011, PLDI '11.

[19]  Frank Tip,et al.  A framework for automated testing of javascript web applications , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[20]  Yepang Liu,et al.  Characterizing and detecting performance bugs for smartphone applications , 2014, ICSE.

[21]  Koushik Sen,et al.  JITProf: pinpointing JIT-unfriendly JavaScript code , 2015, ESEC/SIGSOFT FSE.

[22]  George C. Necula,et al.  EventBreak , 2014, OOPSLA.

[23]  Jan Vitek,et al.  An analysis of the dynamic behavior of JavaScript programs , 2010, PLDI '10.

[24]  Shan Lu,et al.  CARAMEL: Detecting and Fixing Performance Problems That Have Non-Intrusive Fixes , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[25]  Miryung Kim,et al.  Lase: Locating and applying systematic edits by learning from examples , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[26]  Ivan Beschastnikh,et al.  Don't Call Us, We'll Call You: Characterizing Callbacks in Javascript , 2015, 2015 ACM/IEEE International Symposium on Empirical Software Engineering and Measurement (ESEM).

[27]  Lieven Eeckhout,et al.  Statistically rigorous java performance evaluation , 2007, OOPSLA.

[28]  References , 1971 .

[29]  Brian Hackett,et al.  Fast and precise hybrid type inference for JavaScript , 2012, PLDI '12.

[30]  Shan Lu,et al.  Understanding and detecting real-world performance bugs , 2012, PLDI.

[31]  Jan Vitek,et al.  The Eval That Men Do - A Large-Scale Study of the Use of Eval in JavaScript Applications , 2011, ECOOP.

[32]  Gabriele Bavota,et al.  Mining energy-greedy API usage patterns in Android apps: an empirical study , 2014, MSR 2014.

[33]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[34]  Péricles Rafael Oliveira Alves,et al.  Just-in-time value specialization , 2013, Proceedings of the 2013 IEEE/ACM International Symposium on Code Generation and Optimization (CGO).

[35]  Anas N. Al-Rabadi,et al.  A comparison of modified reconstructability analysis and Ashenhurst‐Curtis decomposition of Boolean functions , 2004 .

[36]  Michael Pradel,et al.  Automatically fixing real-world JavaScript performance bugs , 2015, ICSE '15.

[37]  Shan Lu,et al.  Toddler: Detecting performance problems via similar memory-access patterns , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[38]  Anders Møller,et al.  Checking correctness of TypeScript interfaces for JavaScript libraries , 2014, OOPSLA.

[39]  Saurabh Sinha,et al.  Guided test generation for web applications , 2013, 2013 35th International Conference on Software Engineering (ICSE).

[40]  Edith Schonberg,et al.  Finding low-utility data structures , 2010, PLDI '10.

[41]  Ali Mesbah,et al.  Hybrid DOM-Sensitive Change Impact Analysis for JavaScript , 2015, ECOOP.

[42]  Arie van Deursen,et al.  Crawling AJAX by Inferring User Interface State Changes , 2008, 2008 Eighth International Conference on Web Engineering.

[43]  Marti A. Hearst,et al.  Aligning development tools with the way programmers think about code changes , 2007, CHI.

[44]  Wouter Joosen,et al.  You are what you include: large-scale evaluation of remote javascript inclusions , 2012, CCS.

[45]  Thomas R. Gross,et al.  Performance problems you can fix: a dynamic analysis of memoization opportunities , 2015, OOPSLA.

[46]  Josep Torrellas,et al.  Improving JavaScript performance by deconstructing the type system , 2014, PLDI.