25x Performance, Three Optimizations
On December 31st 2024, the author decided to convert their scheme implementation to a CPS-based JIT compiler instead of an AST interpreter. This was done to make creating continuations mechanical. The author compared the performance of their final interpreted version of scheme-rs to Guile, the scheme implementation installed on the most computers, and found that Guile was over 10x faster.
The author then implemented three optimizations to bring scheme-rs back to the same performance level as Guile. The first optimization was the beta reduction step, which eliminated useless functions and reduced overhead. The second optimization involved mapping expressions to primitive operators, allowing for faster execution by avoiding user functions and continuation expressions.
The third optimization focused on fixing the value type for scheme-rs, replacing a giant enum with a more controlled representation.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.