[commit: ghc] master: Lift constructor tag allocation out of a loop (dbdf77d)
git at git.haskell.org
git at git.haskell.org
Wed Jan 10 13:51:21 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/dbdf77d92c9cd0bbb269137de0bf8754573cdc1e/ghc
>---------------------------------------------------------------
commit dbdf77d92c9cd0bbb269137de0bf8754573cdc1e
Author: Bartosz Nitka <niteria at gmail.com>
Date: Fri Jan 5 15:20:05 2018 +0000
Lift constructor tag allocation out of a loop
Before this change, for each constructor that we want
to allocate a tag for we would traverse a list of all
the constructors in a datatype to determine which tag
a constructor should get.
This is obviously quadratic and for datatypes with 10k
constructors it actually makes a big difference.
This change implements the plan outlined by @simonpj in
https://mail.haskell.org/pipermail/ghc-devs/2017-October/014974.html
which is basically about using a map and constructing it outside the
loop.
One place where things got a bit awkward was TysWiredIn.hs,
it would have been possible to just assign the tags by hand, but
that seemed error-prone to me, so I decided to go through a map
there as well.
Test Plan:
./validate
On a file with 10k constructors
Before:
8,130,522,344 bytes allocated in the heap
Total time 3.682s ( 3.920s elapsed)
After:
4,133,478,744 bytes allocated in the heap
Total time 2.509s ( 2.750s elapsed)
Reviewers: simonpj, bgamari
Reviewed By: simonpj
Subscribers: goldfire, rwbarton, thomie, simonmar, carter, simonpj
GHC Trac Issues: #14657
Differential Revision: https://phabricator.haskell.org/D4289
>---------------------------------------------------------------
dbdf77d92c9cd0bbb269137de0bf8754573cdc1e
compiler/basicTypes/DataCon.hs | 5 ++---
compiler/iface/BuildTyCl.hs | 13 +++++++++---
compiler/iface/TcIface.hs | 5 ++++-
compiler/prelude/TysWiredIn.hs | 10 ++++++++-
compiler/typecheck/TcTyClsDecls.hs | 13 +++++++-----
compiler/types/TyCon.hs | 25 ++++++++++++++++++++++-
compiler/vectorise/Vectorise/Generic/PData.hs | 4 ++++
compiler/vectorise/Vectorise/Type/TyConDecl.hs | 2 ++
testsuite/tests/perf/compiler/all.T | 12 +++++++++++
testsuite/tests/perf/compiler/genManyConstructors | 25 +++++++++++++++++++++++
10 files changed, 100 insertions(+), 14 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc dbdf77d92c9cd0bbb269137de0bf8754573cdc1e
More information about the ghc-commits
mailing list