carp-lang / Carp

A statically typed lisp, without a GC, for real-time applications.
Apache License 2.0
5.52k stars 178 forks source link

Profiling the compiler #778

Open eriksvedang opened 4 years ago

eriksvedang commented 4 years ago

So far very little work has gone into making the compiler fast. For the most parts I thinks it's "fast enough", but since there presumably are no big projects written in Carp this is hard to know for sure. I think that profiling the compiler to at least know what parts are slow could be an interesting and worthwhile endeavour. This issue can be a good place for reporting the results and discussing possible improvements.

hellerve commented 4 years ago

A good example for the compiler being mysteriously slow (at least on my machine) is tests/map.carp. That test takes almost 20 seconds to compile.

jacereda commented 4 years ago

795 attaches a flamegraph for that same file. Looks like toC and multiLookupInternal are good candidates.

jacereda commented 4 years ago

Also, flamegraph.sh shows that carp takes almost the same time as clang.

scolsen commented 3 years ago

When I rewrote the env code recently, the biggest hotspots were in exhaustive env lookups (looking for some binder in all parents, used modules, etc.) and emit.hs. This likely hasn't changed. After we do a bit more general clean up and push some fixes for outstanding bugs we can try and tackle this.