Interpreter Performance & Optimizations

Resources

Attention: next week will be a hands on lab. Please bring your laptops.

Quiz

The upstream/student repository now contains quiz #2. If necessary, merge the contents of the upstream repository into your personal repository and commit and push the quiz answers to your personal repository by Tuesday, March 19 2024, 10:30.

Bonus coding task

The bonus coding task from this lecture is to optimize the baseline implementation of the JaraScript interpreter so that the JMH benchmarks included in the repository show a significant improvement over the baseline solution.

The benchmarks can be executed using:

mvn -DskipTests verify

or from IntelliJ using Maven → JaraScript → Lifecycle → verify (you can toggle “Skip Tests” mode using crossed circle icon in the Maven window toolbar).

The goal is not to rewrite the entire interpreter but to find performance left on the table in the straightforward solution. Specifically:

  • You must preserve the AST structure of the interpreter, i.e., Java objects representing AST nodes, and execution implemented as recursive calls of node methods. However, you can modify the existing nodes, add new nodes, etc.

  • You can do whatever you need during the Interpreter#compile step. It is not measured as part of the benchmark.

  • Your optimizations should be general and ± applicable to other (similar, but not the same) benchmarks.

The above rules are intentionally vague and incomplete. Please use common sense in judging what is and is not beyond the point of this exercise. Trying to write down exact rules would be an exercise in futility.

Bonus points awarded:

There are two benchmarks: Fibonacci and PiSum.

  • speedup over straightforward solution (5 points)
    • at least >= 1.5x speedup for one of the benchmarks
    • at least >= 1.2x speedup for the other one

The deadline for completing the bonus task is also Tuesday, March 19 2024, 10:30.