Commit c1d96906 authored by Bartosz Nitka's avatar Bartosz Nitka Committed by niteria
Browse files

Avoid linear lookup in unload_wkr in the Linker

I've encountered an issue with following
reproduction steps:
* `:load` a large number of modules (~2000)
* compile a BCO that depends on many other BCOs from many other modules
* `:reload`
* try to compile anything, even `1` works

Before this patch the last step takes ~5s.
It takes 80ms after.

Test Plan: harbormaster

Reviewers: simonmar, austin, hvr, bgamari

Subscribers: rwbarton, thomie

Differential Revision:
parent cbbf0837
......@@ -1091,13 +1091,13 @@ unload_wkr hsc_env keep_linkables pls = do
filter (not . null . linkableObjs) bcos_to_unload))) $
purgeLookupSymbolCache hsc_env
let bcos_retained = map linkableModule remaining_bcos_loaded
let bcos_retained = mkModuleSet $ map linkableModule remaining_bcos_loaded
-- Note that we want to remove all *local*
-- (i.e. non-isExternal) names too (these are the
-- temporary bindings from the command line).
keep_name (n,_) = isExternalName n &&
nameModule n `elem` bcos_retained
nameModule n `elemModuleSet` bcos_retained
itbl_env' = filterNameEnv keep_name (itbl_env pls)
closure_env' = filterNameEnv keep_name (closure_env pls)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment