[commit: ghc] master: Fix a performance bug in GhcMake.downsweep (1893ba1)
git at git.haskell.org
git at git.haskell.org
Wed May 10 12:06:22 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/1893ba12fe1fa2ade35a62c336594afcd569736e/ghc
>---------------------------------------------------------------
commit 1893ba12fe1fa2ade35a62c336594afcd569736e
Author: Simon Marlow <marlowsd at gmail.com>
Date: Wed May 10 05:05:38 2017 -0700
Fix a performance bug in GhcMake.downsweep
Every time we encountered a non-home module during the downsweep, we
were removing it from the finder cache. That meant we were searching
the filesystem for every import, rather than once per downsweep. The
fix is just to flush the finder cache before the downsweep, and
repopulate it for home modules that haven't changed.
Speeds up downsweep by about 25% on a large example I have.
Test Plan: Harbourmaster
Reviewers: bgamari, niteria, austin, erikd
Reviewed By: bgamari, niteria
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3554
>---------------------------------------------------------------
1893ba12fe1fa2ade35a62c336594afcd569736e
compiler/main/GhcMake.hs | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 4d06b6e..176c086 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -130,6 +130,12 @@ depanal excluded_mods allow_dup_roots = do
text "Chasing modules from: ",
hcat (punctuate comma (map pprTarget targets))])
+ -- Home package modules may have been moved or deleted, and new
+ -- source files may have appeared in the home package that shadow
+ -- external package modules, so we have to discard the existing
+ -- cached finder data.
+ liftIO $ flushFinderCaches hsc_env
+
mod_graphE <- liftIO $ downsweep hsc_env old_graph
excluded_mods allow_dup_roots
mod_graph <- reportImportErrors mod_graphE
@@ -1915,6 +1921,12 @@ summariseFile hsc_env old_summaries file mb_phase obj_allowed maybe_buf
then liftIO $ getObjTimestamp location NotBoot
else return Nothing
hi_timestamp <- maybeGetIfaceDate dflags location
+
+ -- We have to repopulate the Finder's cache because it
+ -- was flushed before the downsweep.
+ _ <- liftIO $ addHomeModuleToFinder hsc_env
+ (moduleName (ms_mod old_summary)) (ms_location old_summary)
+
return old_summary{ ms_obj_date = obj_timestamp
, ms_iface_date = hi_timestamp }
else
@@ -2034,11 +2046,6 @@ summariseModule hsc_env old_summary_map is_boot (L loc wanted_mod)
new_summary location (ms_mod old_summary) src_fn src_timestamp
find_it = do
- -- Don't use the Finder's cache this time. If the module was
- -- previously a package module, it may have now appeared on the
- -- search path, so we want to consider it to be a home module. If
- -- the module was previously a home module, it may have moved.
- uncacheModule hsc_env wanted_mod
found <- findImportedModule hsc_env wanted_mod Nothing
case found of
Found location mod
More information about the ghc-commits
mailing list