Enabling Additional Parallelism in Asynchronous JavaScript Applications

Authors Ellen Arteca, Frank Tip, Max Schäfer



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2021.7.pdf
  • Filesize: 1.12 MB
  • 28 pages

Document Identifiers

Author Details

Ellen Arteca
  • Northeastern University, Boston, MA, USA
Frank Tip
  • Northeastern University, Boston, MA, USA
Max Schäfer
  • GitHub, Oxford, UK

Cite AsGet BibTex

Ellen Arteca, Frank Tip, and Max Schäfer. Enabling Additional Parallelism in Asynchronous JavaScript Applications. In 35th European Conference on Object-Oriented Programming (ECOOP 2021). Leibniz International Proceedings in Informatics (LIPIcs), Volume 194, pp. 7:1-7:28, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2021)
https://doi.org/10.4230/LIPIcs.ECOOP.2021.7

Abstract

JavaScript is a single-threaded programming language, so asynchronous programming is practiced out of necessity to ensure that applications remain responsive in the presence of user input or interactions with file systems and networks. However, many JavaScript applications execute in environments that do exhibit concurrency by, e.g., interacting with multiple or concurrent servers, or by using file systems managed by operating systems that support concurrent I/O. In this paper, we demonstrate that JavaScript programmers often schedule asynchronous I/O operations suboptimally, and that reordering such operations may yield significant performance benefits. Concretely, we define a static side-effect analysis that can be used to determine how asynchronous I/O operations can be refactored so that asynchronous I/O-related requests are made as early as possible, and so that the results of these requests are awaited as late as possible. While our static analysis is potentially unsound, we have not encountered any situations where it suggested reorderings that change program behavior. We evaluate the refactoring on 20 applications that perform file- or network-related I/O. For these applications, we observe average speedups ranging between 0.99% and 53.6% for the tests that execute refactored code (8.1% on average).

Subject Classification

ACM Subject Classification
  • Software and its engineering → Automated static analysis
  • Software and its engineering → Concurrent programming structures
  • Software and its engineering → Software performance
Keywords
  • asynchronous programming
  • refactoring
  • side-effect analysis
  • performance optimization
  • static analysis
  • JavaScript

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Frances E. Allen. Interprocedural data flow analysis. In Jack L. Rosenfeld, editor, Information Processing, Proceedings of the 6th IFIP Congress 1974, Stockholm, Sweden, August 5-10, 1974, pages 398-402. North-Holland, 1974. Google Scholar
  2. Pavel Avgustinov, Oege de Moor, Michael Peyton Jones, and Max Schäfer. QL: object-oriented queries on relational data. In 30th European Conference on Object-Oriented Programming, ECOOP 2016, July 18-22, 2016, Rome, Italy, pages 2:1-2:25, 2016. URL: https://doi.org/10.4230/LIPIcs.ECOOP.2016.2.
  3. Gleb Bahmutov. connect-slow. https://github.com/bahmutov/connect-slow, 2020. Accessed: 2020-12-13.
  4. John Banning. An efficient way to find side effects of procedure calls and aliases of variables. In Alfred V. Aho, Stephen N. Zilles, and Barry K. Rosen, editors, Conference Record of the Sixth Annual ACM Symposium on Principles of Programming Languages, San Antonio, Texas, USA, January 1979, pages 29-41. ACM Press, 1979. URL: https://doi.org/10.1145/567752.567756.
  5. Keith D. Cooper and Ken Kennedy. Interprocedural side-effect analysis in linear time. In Proceedings of the ACM SIGPLAN'88 Conference on Programming Language Design and Implementation (PLDI), Atlanta, Georgia, USA, June 22-24, 1988, pages 57-66, 1988. URL: https://doi.org/10.1145/53990.53996.
  6. Ron Cytron, Jeanne Ferrante, Barry K Rosen, Mark N Wegman, and F Kenneth Zadeck. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems (TOPLAS), 13(4):451-490, 1991. Google Scholar
  7. Danny Dig. Refactoring for asynchronous execution on mobile devices. IEEE Software, 32(6):52-61, 2015. URL: https://doi.org/10.1109/MS.2015.133.
  8. Danny Dig, John Marrero, and Michael D. Ernst. Refactoring sequential Java code for concurrency via concurrent libraries. In 31st International Conference on Software Engineering, ICSE 2009, May 16-24, 2009, Vancouver, Canada, Proceedings, pages 397-407, 2009. URL: https://doi.org/10.1109/ICSE.2009.5070539.
  9. Danny Dig, Mihai Tarce, Cosmin Radoi, Marius Minea, and Ralph E. Johnson. Relooper: refactoring for loop parallelism in Java. In Companion to the 24th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2009, October 25-29, 2009, Orlando, Florida, USA, pages 793-794, 2009. URL: https://doi.org/10.1145/1639950.1640018.
  10. ECMA. Ecmascript 2019 language specification, 2010. Available from URL: http://www.ecma-international.org/ecma-262/.
  11. Keheliya Gallaba, Quinn Hanam, Ali Mesbah, and Ivan Beschastnikh. Refactoring asynchrony in JavaScript. In 2017 IEEE International Conference on Software Maintenance and Evolution, ICSME 2017, Shanghai, China, September 17-22, 2017, pages 353-363. IEEE Computer Society, 2017. URL: https://doi.org/10.1109/ICSME.2017.83.
  12. GitHub. CodeQL. https://github.com/codeql, 2021. Accessed: 2021-01-05.
  13. GitHub. CodeQL standard libraries and queries. https://github.com/github/codeql, 2021. Accessed: 2021-01-05.
  14. Jordan Harband. util.promisify. https://github.com/ljharb/util.promisify, 2020. Accessed: 2020-05-14.
  15. Raffi Khatchadourian, Yiming Tang, Mehdi Bagherzadeh, and Syed Ahmed. Safe automated refactoring for intelligent parallelization of java 8 streams. In Joanne M. Atlee, Tevfik Bultan, and Jon Whittle, editors, Proceedings of the 41st International Conference on Software Engineering, ICSE 2019, Montreal, QC, Canada, May 25-31, 2019, pages 619-630. IEEE / ACM, 2019. URL: https://doi.org/10.1109/ICSE.2019.00072.
  16. Johannes Kloos, Rupak Majumdar, and Frank McCabe. Deferrability analysis for JavaScript. In Haifa Verification Conference, pages 35-50. Springer, 2017. Google Scholar
  17. William Landi, Barbara G. Ryder, and Sean Zhang. Interprocedural modification side effect analysis with pointer aliasing. In In Proceedings of the SIGPLAN '93 Conference on Programming Language Design and Implementation, pages 56-67, 1993. Google Scholar
  18. Christopher Lapkowski and Laurie J Hendren. Extended ssa numbering: Introducing SSA properties to languages with multi-level pointers. In International Conference on Compiler Construction, pages 128-143. Springer, 1998. Google Scholar
  19. Yu Lin, Semih Okur, and Danny Dig. Study and refactoring of Android asynchronous programming (T). In 30th IEEE/ACM International Conference on Automated Software Engineering, ASE 2015, Lincoln, NE, USA, November 9-13, 2015, pages 224-235, 2015. URL: https://doi.org/10.1109/ASE.2015.50.
  20. Yu Lin, Cosmin Radoi, and Danny Dig. Retrofitting concurrency for Android applications through refactoring. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, (FSE-22), Hong Kong, China, November 16 - 22, 2014, pages 341-352, 2014. URL: https://doi.org/10.1145/2635868.2635903.
  21. Magnus Madsen, Frank Tip, and Ondřej Lhoták. Static Analysis of Event-Driven Node.js JavaScript Applications. In Object-Oriented Programming, Systems, Languages & Applications (OOPSLA), 2015. Google Scholar
  22. Gianluca Mezzetti, Anders Møller, and Martin Toldam Torp. Type Regression Testing to Detect Breaking Changes in Node.js Libraries. In Todd D. Millstein, editor, 32nd European Conference on Object-Oriented Programming, ECOOP 2018, July 16-21, 2018, Amsterdam, The Netherlands, volume 109 of LIPIcs, pages 7:1-7:24. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2018. Google Scholar
  23. Semih Okur, Cansu Erdogan, and Danny Dig. Converting parallel code from low-level abstractions to higher-level abstractions. In ECOOP 2014 - Object-Oriented Programming - 28th European Conference, Uppsala, Sweden, July 28 - August 1, 2014. Proceedings, pages 515-540, 2014. URL: https://doi.org/10.1007/978-3-662-44202-9_21.
  24. Semih Okur, David L. Hartveld, Danny Dig, and Arie van Deursen. A study and toolkit for asynchronous programming in C#. In 36th International Conference on Software Engineering, ICSE '14, Hyderabad, India - May 31 - June 07, 2014, pages 1117-1127, 2014. URL: https://doi.org/10.1145/2568225.2568309.
  25. pandas. pandas. https://pandas.pydata.org, 2020. Accessed: 2020-12-13.
  26. Cosmin Radoi and Danny Dig. Practical static race detection for Java parallel loops. In International Symposium on Software Testing and Analysis, ISSTA '13, Lugano, Switzerland, July 15-20, 2013, pages 178-190, 2013. URL: https://doi.org/10.1145/2483760.2483765.
  27. Veselin Raychev, Martin Vechev, and Manu Sridharan. Effective race detection for event-driven programs. In ACM SIGPLAN Notices, volume 48, pages 151-166. ACM, 2013. Google Scholar
  28. Max Schäfer and Oege de Moor. Specifying and implementing refactorings. In William R. Cook, Siobhán Clarke, and Martin C. Rinard, editors, Proceedings of the 25th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2010, October 17-21, 2010, Reno/Tahoe, Nevada, USA, pages 286-301. ACM, 2010. URL: https://doi.org/10.1145/1869459.1869485.
  29. Max Schäfer, Julian Dolby, Manu Sridharan, Emina Torlak, and Frank Tip. Correct refactoring of concurrent Java code. In ECOOP 2010 - Object-Oriented Programming, 24th European Conference, Maribor, Slovenia, June 21-25, 2010. Proceedings, pages 225-249, 2010. URL: https://doi.org/10.1007/978-3-642-14107-2_11.
  30. Isaac Z. Schlueter. graceful-fs. https://www.npmjs.com/package/graceful-fs, 2020. Accessed: 2020-05-14.
  31. Thomas C. Spillman. Exposing side-effects in a PL/I optimizing compiler. In Information Processing, Proceedings of IFIP Congress 1971, Volume 1 - Foundations and Systems, Ljubljana, Yugoslavia, August 23-28, 1971, pages 376-381, 1971. Google Scholar
  32. Jan Wloka, Manu Sridharan, and Frank Tip. Refactoring for reentrancy. In Proceedings of the 7th joint meeting of the European Software Engineering Conference and the ACM SIGSOFT International Symposium on Foundations of Software Engineering, 2009, Amsterdam, The Netherlands, August 24-28, 2009, pages 173-182, 2009. URL: https://doi.org/10.1145/1595696.1595723.
  33. Ryan Zim. universalify. https://github.com/RyanZim/universalify, 2020. Accessed: 2020-05-14.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail