Skip to content

Improving the compilation speed of TH generated parsing code from mkYesodData #1889

@TeofilC

Description

@TeofilC

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions