pure-c/purec

Improve compiler performance

felixSchl opened this issue · 3 comments

Currently compiling Data.Either.Nested takes about 10 seconds. It emits about 84k lines of code! So we should (a) investigate optimization passes to remove the lines to output and (b) make it run fast even when generating large files like that.

Have you tried just using Writer with String instead of [String] and interclatate ""? Those array operations are going to be hell on large files. Alternatively, maybe use the Buffer API for more efficient string building.

Thank you for that idea, it might be a quick win. The current implementation was focused on making the code easy for me to keep mapped in my head by removing noise where possible. The emitter should never need to back track, or even look at the mess it printed, so we might as well stream the output.

Just a quick update: the above mentioned compile times where so high because of acidental additional recursing during a recursive ast transform. Compile times are pretty acceptable atm.