We have an internal dhall library, which is pretty new and not that big (~1400 lines, not that heavily commented so that’s mostly code). It’s a “boilerplate” library, where you import it and (using dhall to-directory-tree) you can use a bunch of types and functions to generate various common CI files.
Over time it feels like it’s gotten slower than it should be, so I was hoping to dig in and see if there was an obvious culprit. For reference it’s taking 5s to simply load + typecheck, not counting any actual work. I’m testing this by reexporting
Prelude, and running:
time dhall <<< '(./package.dhall).Prelude.Bool.not True' False real 0m5.140s user 0m4.748s
The only external dependency is the prelude, which is frozen, so nothing’s hitting the network. And if I import the prelude import directly it only takes a fraction of that time:
time dhall <<< '(./dependencies/prelude.dhall).Bool.not True' False real 0m0.144s user 0m0.119s
At a gut level, this feels wrong. We haven’t written that much code, and the prelude is something like 3-4x the number of lines. Admittedly ours is probably more dense (less comments, more complex types) than the Prelude, but it still feels excessive.
I’ve tried a few things, following hunches:
- frozen all imports in all dhall files: no noticeable difference
- tried to surgically comment out imports / functions
I’ve seen some effect getting the evaluation time down by commenting out various parts, but it’s very hard for me to tell if that’s because I’ve found a suspiciously expensive branch, or that code just happens to be bringing in a bunch of transitive expressions which ought to be expensive.
So, any suggestions as to how to continue? I’ve been trying to find a reproduction case I can share, but no real luck so far.
One remaining hunch I don’t know how to check is my suspicion around the JSON type. Since we’re using dhall-to-directory-tree we’ve got a lot of functions mapping custom types into
JSON.Type, and perhaps with the way it’s encoding that recursion it’s having an outsize effect on type checking?