Skip to content
Snippets Groups Projects
Commit 9654a7cf authored by Joachim Breitner's avatar Joachim Breitner
Browse files

Call Arity: Trade precision for performance in large mutually recursive groups

Sometimes (especial with derived Data instances, it seems), one can have
very large mutually recursive bindings. Calculating the Call Arity
analysis result with full precision is an expensive operation in these
case. So above a certain threshold (25, for no good reason besides
intuition), skip this calculation and assume the recursion is not
linear, which is a conservative result.

With this, the Call Arity analysis accounts for 3.7% of the compile time
of haskell-src-exts. Fixes #10293

Differential Revision: https://phabricator.haskell.org/D843
parent a9ca67f6
No related branches found
No related tags found
No related merge requests found
......@@ -630,6 +630,9 @@ callArityRecEnv any_boring ae_rhss ae_body
cross_calls
-- See Note [Taking boring variables into account]
| any_boring = completeGraph (domRes ae_combined)
-- Also, calculating cross_calls is expensive. Simply be conservative
-- if the mutually recursive group becomes too large.
| length ae_rhss > 25 = completeGraph (domRes ae_combined)
| otherwise = unionUnVarGraphs $ map cross_call ae_rhss
cross_call (v, ae_rhs) = completeBipartiteGraph called_by_v called_with_v
where
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment