JPenuchot / poacher

poacher: C++ compile-time compiling experiments
6 stars 1 forks source link

brainfuck::to_ir: Improving performance #1

Closed JPenuchot closed 2 years ago

JPenuchot commented 3 years ago

brainfuck::to_ir has incrediply poor performance on large Brainfuck programs due to its inner workings: as an AST cannot be stored in a constexpr variable. The only workaround that was found is to build constexpr lambdas that allow us to explore the AST by evaluating it completely and returning its different nodes (see brainfuck/ast_to_ir.hpp header). This makes the AST conversion way too slow, its complexity still has to be determined but I suspect it to be O(N²).

JPenuchot commented 2 years ago

New "flat" backend was added, with much scalable performance and (subjectively) cleaner code, with compile-time benchmarks demonstrating performance superiority.