Larose, Octave, Kaleba, Sophie, Burchell, Humphrey, Marr, Stefan (2023) AST vs. bytecode: interpreters in the age of meta-compilation. Proceedings of the ACM on Programming Languages, 7 (OOPSLA). pp. 318-346. ISSN 2475-1421. E-ISSN 2475-1421. (doi:10.1145/3622808) (KAR id:102817)
PDF
Publisher pdf
Language: English
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
|
|
Download this file (PDF/562kB) |
Preview |
Request a format suitable for use with assistive technology e.g. a screenreader | |
PDF
Author's Accepted Manuscript
Language: English Restricted to Repository staff only |
|
Contact us about this Publication
|
![]() |
Official URL: https://doi.org/10.1145/3622808 |
Abstract
Thanks to partial evaluation and meta-tracing, it became practical to build language implementations that reach state-of-the-art peak performance by implementing only an interpreter. Systems such as RPython and GraalVM provide components such as a garbage collector and just-in-time compiler in a language-agnostic manner, greatly reducing implementation effort. However, meta-compilation-based language implementations still need to improve further to reach the low memory use and fast warmup behavior that custom-built systems provide. A key element in this endeavor is interpreter performance. Folklore tells us that bytecode interpreters are superior to abstract-syntax-tree (AST) interpreters both in terms of memory use and run-time performance.
This work assesses the trade-offs between AST and bytecode interpreters to verify common assumptions and whether they hold in the context of meta-compilation systems. We implemented four interpreters, each an AST and a bytecode one using RPython and GraalVM. We keep the difference between the interpreters as small as feasible to be able to evaluate interpreter performance, peak performance, warmup, memory use, and the impact of individual optimizations.
Our results show that both systems indeed reach performance close to Node.js/V8. Looking at interpreter-only performance, our AST interpreters are on par with, or even slightly faster than their bytecode counterparts. After just-in-time compilation, the results are roughly on par. This means bytecode interpreters do not have their widely assumed performance advantage. However, we can confirm that bytecodes are more compact in memory than ASTs, which becomes relevant for larger applications. However, for smaller applications, we noticed that bytecode interpreters allocate more memory because boxing avoidance is not as applicable, and because the bytecode interpreter structure requires memory, e.g., for a reified stack.
Our results show AST interpreters to be competitive on top of meta-compilation systems. Together with possible engineering benefits, they should thus not be discounted so easily in favor of bytecode interpreters.
Item Type: | Article |
---|---|
DOI/Identification number: | 10.1145/3622808 |
Additional information: | For the purpose of open access, the author has applied a CC BY public copyright licence (where permitted by UKRI, an Open Government Licence or CC BY ND public copyright licence may be used instead) to any Author Accepted Manuscript version arising. |
Uncontrolled keywords: | bytecode; abstract-syntax-tree; language implementation; just-in-time compilation; meta-tracing; partial evaluation; comparison; case study; interpreters |
Subjects: | Q Science |
Divisions: | Divisions > Division of Computing, Engineering and Mathematical Sciences > School of Computing |
Funders: |
Engineering and Physical Sciences Research Council (https://ror.org/0439y7842)
Royal Society (https://ror.org/03wnrjx87) |
Depositing User: | Stefan Marr |
Date Deposited: | 18 Sep 2023 21:18 UTC |
Last Modified: | 13 Feb 2024 11:06 UTC |
Resource URI: | https://kar.kent.ac.uk/id/eprint/102817 (The current URI for this page, for reference purposes) |
- Link to SensusAccess
- Export to:
- RefWorks
- EPrints3 XML
- BibTeX
- CSV
- Depositors only (login required):