diff options
author | Simon Jakobi <simon.jakobi@gmail.com> | 2020-03-31 01:19:53 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-05-14 03:31:21 -0400 |
commit | c05c06596bd1b2852454af6243fc15ee852d2f45 (patch) | |
tree | 7fc5f0c23f18521a08cda064d4a94cba4d162c22 /compiler/GHC/Data | |
parent | c9f5a8f4653c4696a1fbb768bd0d8f672d4c7d5f (diff) | |
download | haskell-c05c06596bd1b2852454af6243fc15ee852d2f45.tar.gz |
Improve some folds over Uniq[D]FM
* Replace some non-deterministic lazy folds with
strict folds.
* Replace some O(n log n) folds in deterministic order
with O(n) non-deterministic folds.
* Replace some folds with set-operations on the underlying
IntMaps.
This reduces max residency when compiling
`nofib/spectral/simple/Main.hs` with -O0 by about 1%.
Maximum residency when compiling Cabal also seems reduced on the
order of 3-9%.
Diffstat (limited to 'compiler/GHC/Data')
-rw-r--r-- | compiler/GHC/Data/Graph/Ops.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/GHC/Data/Graph/Ops.hs b/compiler/GHC/Data/Graph/Ops.hs index 7d9ce669c6..61f8bfe431 100644 --- a/compiler/GHC/Data/Graph/Ops.hs +++ b/compiler/GHC/Data/Graph/Ops.hs @@ -79,8 +79,8 @@ addNode k node graph = let -- add back conflict edges from other nodes to this one map_conflict = - nonDetFoldUniqSet - -- It's OK to use nonDetFoldUFM here because the + nonDetStrictFoldUniqSet + -- It's OK to use a non-deterministic fold here because the -- operation is commutative (adjustUFM_C (\n -> n { nodeConflicts = addOneToUniqSet (nodeConflicts n) k})) @@ -89,8 +89,8 @@ addNode k node graph -- add back coalesce edges from other nodes to this one map_coalesce = - nonDetFoldUniqSet - -- It's OK to use nonDetFoldUFM here because the + nonDetStrictFoldUniqSet + -- It's OK to use a non-deterministic fold here because the -- operation is commutative (adjustUFM_C (\n -> n { nodeCoalesce = addOneToUniqSet (nodeCoalesce n) k})) @@ -492,9 +492,9 @@ freezeNode k else node -- panic "GHC.Data.Graph.Ops.freezeNode: edge to freeze wasn't in the coalesce set" -- If the edge isn't actually in the coelesce set then just ignore it. - fm2 = nonDetFoldUniqSet (adjustUFM_C (freezeEdge k)) fm1 - -- It's OK to use nonDetFoldUFM here because the operation - -- is commutative + fm2 = nonDetStrictFoldUniqSet (adjustUFM_C (freezeEdge k)) fm1 + -- It's OK to use a non-deterministic fold here because the + -- operation is commutative $ nodeCoalesce node in fm2 |