summaryrefslogtreecommitdiff
path: root/ghc/Main.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2019-08-17 18:35:09 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2019-08-17 18:35:09 +0100
commit5cff43d301b0773e2deeedb0a397da5e47cb89e1 (patch)
tree074d42d6a9cd8e82703b298d7f55b1078416dcd6 /ghc/Main.hs
parent47e162374051ed3e874ed7916cc811df288cbd95 (diff)
downloadhaskell-wip/faststring-allocs.tar.gz
FastString: Reimplement in terms of pointer equalitywip/faststring-allocs
GHC allocates a lot of FastStrings when compiling so reducing the overhead of a FastString will result in a large decrease in allocations. Therefore we remove all the unecessary fields from the FastString. 1. Unique: Computed from the pointer 2. Equality: Computed directly by comparing the pointer 3. Length: Only used in 3 places, so the overhead is not worth it. 4. HasZEncoding: Caching the zencoding for a string should be localised to code generation rather than any consumer having to pay a large allocation penalty. Comparing pointer equality is safe as the string table guarantees that each string is only allocated once. As the memory is pinned, we don't have to worry about GC moving around the locations of the strings. Thanks to Jamie (Hanue) Willis for suggesting the idea of using pointer equality.
Diffstat (limited to 'ghc/Main.hs')
-rw-r--r--ghc/Main.hs4
1 files changed, 0 insertions, 4 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs
index 614b45f277..3b32c2de99 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -819,7 +819,6 @@ dumpFastStringStats dflags = do
bucketsPerSegment = map length segments
entriesPerBucket = map length buckets
entries = sum entriesPerBucket
- hasZ = sum $ map (length . filter hasZEncoding) buckets
msg = text "FastString stats:" $$ nest 4 (vcat
[ text "segments: " <+> int (length segments)
, text "buckets: " <+> int (sum bucketsPerSegment)
@@ -827,7 +826,6 @@ dumpFastStringStats dflags = do
, text "largest segment: " <+> int (maximum bucketsPerSegment)
, text "smallest segment: " <+> int (minimum bucketsPerSegment)
, text "longest bucket: " <+> int (maximum entriesPerBucket)
- , text "has z-encoding: " <+> (hasZ `pcntOf` entries)
])
-- we usually get more "has z-encoding" than "z-encoded", because
-- when we z-encode a string it might hash to the exact same string,
@@ -835,8 +833,6 @@ dumpFastStringStats dflags = do
-- Z-encoding is different from the original string are counted in
-- the "z-encoded" total.
putMsg dflags msg
- where
- x `pcntOf` y = int ((x * 100) `quot` y) Outputable.<> char '%'
showPackages, dumpPackages, dumpPackagesSimple :: DynFlags -> IO ()
showPackages dflags = putStrLn (showSDoc dflags (pprPackages dflags))