-
Notifications
You must be signed in to change notification settings - Fork 381
Description
A while ago, I looked into the performance of compiling the code generated by mkYesodData. While the TH generation runs quite quickly, the compilation of the generated code is slow.
In particular, the generated route parsing code creates a giant case statement with a lot of view patterns. I'm suspicious that a lot the slowness comes from this. I remember finding some evidence that this was the case, but I can't remember precisely.
Case staments on strings/text values are also O(n), so this is also likely generating suboptimal code (especially if you have lots of routes).
I don't use yesod anymore, so I probably won't look into this any further any time soon.
But this might a good avenue to investigate for someone hitting bad compile times.
Perhaps it would be generating something like a trie (although handling capture parsing might be annoying, and require turning things into Any) or just parser combinators.
I recall the other generated code also being suboptimal, but the parsing code seemed especially bad.