summaryrefslogtreecommitdiff
path: root/compiler/main/DriverMkDepend.hs
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2017-06-27 12:55:17 -0400
committerBen Gamari <ben@smart-cactus.org>2017-06-27 13:34:05 -0400
commitb0708588e87554899c2efc80a2d3eba353dbe926 (patch)
tree03817b07a5c542a45d6058cf19a09efeaf5037bc /compiler/main/DriverMkDepend.hs
parent6567c815135e93f8550d526f81d13f31c0cd92b6 (diff)
downloadhaskell-b0708588e87554899c2efc80a2d3eba353dbe926.tar.gz
Make module membership on ModuleGraph faster
When loading/reloading with a large number of modules (>5000) the cost of linear lookups becomes significant. The changes here made `:reload` go from 6s to 1s on my test case. The bottlenecks were `needsLinker` in `DriverPipeline` and `getModLoop` in `GhcMake`. Test Plan: ./validate Reviewers: simonmar, austin, bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3646
Diffstat (limited to 'compiler/main/DriverMkDepend.hs')
-rw-r--r--compiler/main/DriverMkDepend.hs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/main/DriverMkDepend.hs b/compiler/main/DriverMkDepend.hs
index dc18a31174..8cf14c57e5 100644
--- a/compiler/main/DriverMkDepend.hs
+++ b/compiler/main/DriverMkDepend.hs
@@ -75,11 +75,11 @@ doMkDependHS srcs = do
targets <- mapM (\s -> GHC.guessTarget s Nothing) srcs
GHC.setTargets targets
let excl_mods = depExcludeMods dflags
- mod_summaries <- GHC.depanal excl_mods True {- Allow dup roots -}
+ module_graph <- GHC.depanal excl_mods True {- Allow dup roots -}
-- Sort into dependency order
-- There should be no cycles
- let sorted = GHC.topSortModuleGraph False mod_summaries Nothing
+ let sorted = GHC.topSortModuleGraph False module_graph Nothing
-- Print out the dependencies if wanted
liftIO $ debugTraceMsg dflags 2 (text "Module dependencies" $$ ppr sorted)
@@ -91,7 +91,7 @@ doMkDependHS srcs = do
mapM_ (liftIO . processDeps dflags hsc_env excl_mods root (mkd_tmp_hdl files)) sorted
-- If -ddump-mod-cycles, show cycles in the module graph
- liftIO $ dumpModCycles dflags mod_summaries
+ liftIO $ dumpModCycles dflags module_graph
-- Tidy up
liftIO $ endMkDependHS dflags files
@@ -338,8 +338,8 @@ endMkDependHS dflags
-- Module cycles
-----------------------------------------------------------------
-dumpModCycles :: DynFlags -> [ModSummary] -> IO ()
-dumpModCycles dflags mod_summaries
+dumpModCycles :: DynFlags -> ModuleGraph -> IO ()
+dumpModCycles dflags module_graph
| not (dopt Opt_D_dump_mod_cycles dflags)
= return ()
@@ -351,7 +351,8 @@ dumpModCycles dflags mod_summaries
where
cycles :: [[ModSummary]]
- cycles = [ c | CyclicSCC c <- GHC.topSortModuleGraph True mod_summaries Nothing ]
+ cycles =
+ [ c | CyclicSCC c <- GHC.topSortModuleGraph True module_graph Nothing ]
pp_cycles = vcat [ (text "---------- Cycle" <+> int n <+> ptext (sLit "----------"))
$$ pprCycle c $$ blankLine
@@ -379,7 +380,8 @@ pprCycle summaries = pp_group (CyclicSCC summaries)
loop_breaker = head boot_only
all_others = tail boot_only ++ others
- groups = GHC.topSortModuleGraph True all_others Nothing
+ groups =
+ GHC.topSortModuleGraph True (mkModuleGraph all_others) Nothing
pp_ms summary = text mod_str <> text (take (20 - length mod_str) (repeat ' '))
<+> (pp_imps empty (map snd (ms_imps summary)) $$