pure-c / purec

C backend for PureScript
232 stars 8 forks source link

Improve compiler performance #30

Open felixSchl opened 5 years ago

felixSchl commented 5 years ago

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.

natefaubion commented 5 years ago

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.

felixSchl commented 5 years ago

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.

felixSchl commented 5 years ago

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.