[Git][ghc/ghc][wip/haddock-mem-fixes] 3 commits: Memory usage fixes for Haddock
Finley McIlwaine (@FinleyMcIlwaine)
gitlab at gitlab.haskell.org
Thu Jun 8 22:27:18 UTC 2023
Finley McIlwaine pushed to branch wip/haddock-mem-fixes at Glasgow Haskell Compiler / GHC
Commits:
0887aa3e by Finley McIlwaine at 2023-06-08T16:26:19-06:00
Memory usage fixes for Haddock
- Do not include `mi_globals` in the `NoBackend` backend. It was only included
for Haddock, but Haddock does not actually need it. This causes a 200MB
reduction in max residency when generating haddocks on the Agda codebase
(roughly 1GB to 800MB).
- Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to
be written to interface files using `-fwrite-interface`
- - - - -
e55d7d1f by Finley McIlwaine at 2023-06-08T16:26:41-06:00
Fix associated data family doc structure items
Associated data families were being given their own export DocStructureItems,
which resulted in them being documented separately from their classes in
haddocks. This commit fixes it.
- - - - -
f8fe1858 by Finley McIlwaine at 2023-06-08T16:26:41-06:00
Bump haddock submodule
- - - - -
6 changed files:
- compiler/GHC/Driver/Backend.hs
- compiler/GHC/Hs/Doc.hs
- compiler/GHC/HsToCore/Docs.hs
- testsuite/tests/haddock/perf/Fold.hs
- testsuite/tests/haddock/perf/Makefile
- utils/haddock
Changes:
=====================================
compiler/GHC/Driver/Backend.hs
=====================================
@@ -551,17 +551,14 @@ backendRespectsSpecialise (Named NoBackend) = False
-- | This back end wants the `mi_globals` field of a
-- `ModIface` to be populated (with the top-level bindings
--- of the original source). True for the interpreter, and
--- also true for "no backend", which is used by Haddock.
--- (After typechecking a module, Haddock wants access to
--- the module's `GlobalRdrEnv`.)
+-- of the original source). Only true for the interpreter.
backendWantsGlobalBindings :: Backend -> Bool
backendWantsGlobalBindings (Named NCG) = False
backendWantsGlobalBindings (Named LLVM) = False
backendWantsGlobalBindings (Named ViaC) = False
backendWantsGlobalBindings (Named JavaScript) = False
+backendWantsGlobalBindings (Named NoBackend) = False
backendWantsGlobalBindings (Named Interpreter) = True
-backendWantsGlobalBindings (Named NoBackend) = True
-- | The back end targets a technology that implements
-- `switch` natively. (For example, LLVM or C.) Therefore
=====================================
compiler/GHC/Hs/Doc.hs
=====================================
@@ -123,7 +123,7 @@ type LHsDoc pass = Located (HsDoc pass)
data DocStructureItem
= DsiSectionHeading !Int !(HsDoc GhcRn)
| DsiDocChunk !(HsDoc GhcRn)
- | DsiNamedChunkRef !(String)
+ | DsiNamedChunkRef !String
| DsiExports !Avails
| DsiModExport
!(NonEmpty ModuleName) -- ^ We might re-export avails from multiple
=====================================
compiler/GHC/HsToCore/Docs.hs
=====================================
@@ -31,18 +31,18 @@ import Data.Bifunctor (first)
import Data.Foldable (toList)
import Data.IntMap (IntMap)
import qualified Data.IntMap as IM
+import qualified Data.List.NonEmpty as NonEmpty
+import Data.List.NonEmpty (NonEmpty ((:|)))
import Data.Map.Strict (Map)
import qualified Data.Map as M
-import qualified Data.Set as Set
import Data.Maybe
+import qualified Data.Set as Set
import Data.Semigroup
import GHC.IORef (readIORef)
import GHC.Unit.Types
import GHC.Hs
import GHC.Types.Avail
import GHC.Unit.Module
-import qualified Data.List.NonEmpty as NonEmpty
-import Data.List.NonEmpty (NonEmpty ((:|)))
import GHC.Unit.Module.Imported
import GHC.Driver.DynFlags
import GHC.Types.TypeEnv
@@ -192,7 +192,13 @@ mkDocStructureFromDecls env all_exports decls =
Just loc -> L loc (DsiExports [avail])
-- FIXME: This is just a workaround that we use when handling e.g.
-- associated data families like in the html-test Instances.hs.
- Nothing -> noLoc (DsiExports [avail])
+ Nothing -> noLoc (DsiExports [])
+
+ -- This causes the associated data family to be incorrectly documented
+ -- separately from its class:
+ -- Nothing -> noLoc (DsiExports [avail])
+
+ -- This panics on the associated data family:
-- Nothing -> panicDoc "mkDocStructureFromDecls: No loc found for"
-- (ppr avail)
=====================================
testsuite/tests/haddock/perf/Fold.hs
=====================================
@@ -143,6 +143,7 @@ import Prelude
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import Control.Monad as Monad
+import Control.Monad.Fix
import Control.Monad.Reader
import qualified Control.Monad.Reader as Reader
import Data.Functor
=====================================
testsuite/tests/haddock/perf/Makefile
=====================================
@@ -4,12 +4,12 @@ include $(TOP)/mk/test.mk
# We accept a 5% increase in parser allocations due to -haddock
haddock_parser_perf :
- WithHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fforce-recomp -Wno-all -ddump-timings -haddock -O0 Fold.hs 2>/dev/null | grep Parser | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
- WithoutHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fforce-recomp -Wno-all -ddump-timings -O0 Fold.hs 2>/dev/null | grep Parser | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
+ WithHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fwrite-interface -fforce-recomp -Wno-all -ddump-timings -haddock -O0 Fold.hs 2>/dev/null | grep Parser | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
+ WithoutHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fwrite-interface -fforce-recomp -Wno-all -ddump-timings -O0 Fold.hs 2>/dev/null | grep Parser | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
awk "BEGIN { ratio = ($$WithHaddock / $$WithoutHaddock); if (ratio > 1.05) {print \"-haddock allocation ratio too high:\", ratio; exit 1} else {exit 0} }"
# Similarly for the renamer
haddock_renamer_perf :
- WithoutHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fforce-recomp -Wno-all -ddump-timings -O0 Fold.hs 2>/dev/null | grep Renamer | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
- WithHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fforce-recomp -Wno-all -ddump-timings -haddock -O0 Fold.hs 2>/dev/null | grep Renamer | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
- awk "BEGIN { ratio = ($$WithHaddock / $$WithoutHaddock); if (ratio > 1.20) {print \"-haddock allocation ratio too high:\", ratio; exit 1} else {exit 0} }"
+ WithoutHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fwrite-interface -fforce-recomp -Wno-all -ddump-timings -O0 Fold.hs 2>/dev/null | grep Renamer | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
+ WithHaddock=$(shell '$(TEST_HC)' $(TEST_HC_OPTS) -fno-code -fwrite-interface -fforce-recomp -Wno-all -ddump-timings -haddock -O0 Fold.hs 2>/dev/null | grep Renamer | grep -E -o 'alloc=[0-9]+' | cut -c7- ) ; \
+ awk "BEGIN { ratio = ($$WithHaddock / $$WithoutHaddock); if (ratio > 1.05) {print \"-haddock allocation ratio too high:\", ratio; exit 1} else {exit 0} }"
=====================================
utils/haddock
=====================================
@@ -1 +1 @@
-Subproject commit 30cf825972c53d97d6add9aa0e61bcb32ccc3ad1
+Subproject commit 61b0845b3e3268b469db8bb20fd3d19118453727
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ea070f1d4771fdb13fa0b83f0bea9d1be7aac76...f8fe18581bfb1edc86444ced1ac44fcd70c50a86
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7ea070f1d4771fdb13fa0b83f0bea9d1be7aac76...f8fe18581bfb1edc86444ced1ac44fcd70c50a86
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230608/fbd5a887/attachment-0001.html>
More information about the ghc-commits
mailing list