Debugging compile time performance issues caused by GHC's constraint solver -


haskell has many great tools debugging run time performance issues, tools/rules of thumb exist debugging compile time performance issues?

specifically, constraint solver in of code taking forever (anywhere 1-2 seconds several minutes). i'm pretty sure due how i'm using type families in constraints, have no idea sort of things expensive in context or how see constraint solver spending time. best guess 1 of operations on type lists taking quadratic time instead of linear.

let's see example of why suspect constraint solver. in files, have code looks like:

class exampleclass     type exampletype     f :: exampletype ->  data exampledata (xs :: [a]) = ...  instance      ( constraint1     , constraint2     , ...     ) => exampleclass (exampledata xs)              type exampletype (exampledata xs) = int     f = undefined 

when load file ghci

ghci> :l example.hs 

compilation happens quickly, less 1 second. then, execute following line:

ghci> let test = f int :: exampledata 

no actual computation going on, still takes long time. more constraints in exampledata's instance declaration, longer takes. (actually evaluating test later happens instantly.) best way i've figured out how debug these performance issues commenting out constraints one-by-one , seeing ones causing performance hit. time consuming, , when constraints involve complex type families, it's not informative.

so, there better approach can take debug problem?


edit: turns out discovered bug in ghc. there's script associated bug demonstrates constraint solver taking quadratic time on inputs should linear.

for it's worth, can evaluate constraints 1 @ time using :kind! see how long takes, instead of needing comment them out individually.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -