Make `PackageName` type opaque (#3896)
commitdabd9d9837539dfb3a7647ace074a3e2df14cc3b
authorHerbert Valerio Riedel <hvr@gnu.org>
Tue, 27 Sep 2016 08:03:06 +0000 (27 10:03 +0200)
committerGitHub <noreply@github.com>
Tue, 27 Sep 2016 08:03:06 +0000 (27 10:03 +0200)
treedca800d4e613c1fab7a6805ede1685581e8856aa
parent2ccfce176d4b6dc88daed7b8ccd75de0f4337336
Make `PackageName` type opaque (#3896)

When looking at heap-profiles of `cabal-install`, the `(:)` constructor
stands out as the most-allocated constructor on the heap.

Having to handle 10k+ package names contributes to the allocation
numbers, especially on 64bit archs where ASCII `String`s have a 24 byte
per character footprint.

This commit is a preparatory commit to pave the way for changing
`PackageName`'s internal representation to something like
`ShortByteString` (which is essentially a thin wrapper around primitive
`ByteArray#`s which themselves have have an overhead of 2 words + one
byte per ASCII character rounded up to nearest word) which would allow
to reduce the memory footprint by a full order of magnitude, as well as
reduce pointer chasing and GC overhead.
39 files changed:
Cabal/Distribution/InstalledPackageInfo.hs
Cabal/Distribution/Package.hs
Cabal/Distribution/PackageDescription/Check.hs
Cabal/Distribution/ParseUtils.hs
Cabal/Distribution/Simple/Build.hs
Cabal/Distribution/Simple/Configure.hs
Cabal/Distribution/Simple/GHC.hs
Cabal/Distribution/Simple/GHC/IPIConvert.hs
Cabal/Distribution/Simple/Haddock.hs
Cabal/Distribution/Simple/PackageIndex.hs
Cabal/Distribution/Simple/PreProcess.hs
Cabal/Distribution/Types/PackageDescription.hs
Cabal/changelog
Cabal/tests/PackageTests/BenchmarkStanza/Check.hs
Cabal/tests/PackageTests/CaretOperator/Check.hs
Cabal/tests/PackageTests/TestStanza/Check.hs
cabal-install/Distribution/Client/BuildReports/Anonymous.hs
cabal-install/Distribution/Client/Dependency.hs
cabal-install/Distribution/Client/GenBounds.hs
cabal-install/Distribution/Client/IndexUtils.hs
cabal-install/Distribution/Client/Init/Heuristics.hs
cabal-install/Distribution/Client/List.hs
cabal-install/Distribution/Client/PackageUtils.hs
cabal-install/Distribution/Client/ProjectPlanning.hs
cabal-install/Distribution/Client/SetupWrapper.hs
cabal-install/Distribution/Client/SolverInstallPlan.hs
cabal-install/Distribution/Client/SolverPlanIndex.hs
cabal-install/Distribution/Client/Targets.hs
cabal-install/Distribution/Solver/Modular/Index.hs
cabal-install/Distribution/Solver/Modular/IndexConversion.hs
cabal-install/Distribution/Solver/Modular/Package.hs
cabal-install/Distribution/Solver/Modular/Solver.hs
cabal-install/Distribution/Solver/Types/PackageIndex.hs
cabal-install/Distribution/Solver/Types/PkgConfigDb.hs
cabal-install/tests/IntegrationTests2.hs
cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs
cabal-install/tests/UnitTests/Distribution/Client/InstallPlan.hs
cabal-install/tests/UnitTests/Distribution/Client/Targets.hs
cabal-install/tests/UnitTests/Distribution/Solver/Modular/DSL.hs