[commit: ghc] master: Refactor derived Generic instances to reduce allocations (9649fc0)

git at git.haskell.org git at git.haskell.org
Sat Jun 18 22:23:28 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9649fc0ae45e006c2ed54cc5ea2414158949fadb/ghc

>---------------------------------------------------------------

commit 9649fc0ae45e006c2ed54cc5ea2414158949fadb
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sat Jun 18 12:23:12 2016 +0200

    Refactor derived Generic instances to reduce allocations
    
    Previously, derived implementations of `to`/`from` in `Generic`
    instances were wastefully putting extra `M1`s in every case, which led
    to an O(n) increase in the number of coercions, resulting in a slowdown
    during the typechecker phase.
    
    This factors out the common `M1` in every case of a `to`/`from`
    definition so that the typechecker has far fewer coercions to deal with.
    For a datatype with 300 constructors, this change has been observed to
    save almost 3 seconds of compilation time.
    
    This is one step towards coming up with a solution for #5642.
    
    Test Plan: ./validate
    
    Reviewers: hvr, austin, simonpj, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: basvandijk, carter, thomie, osa1
    
    Differential Revision: https://phabricator.haskell.org/D2304
    
    GHC Trac Issues: #5642


>---------------------------------------------------------------

9649fc0ae45e006c2ed54cc5ea2414158949fadb
 compiler/typecheck/TcGenGenerics.hs                |  83 ++++-
 testsuite/tests/generics/GenDerivOutput.stderr     | 144 ++++----
 testsuite/tests/generics/GenDerivOutput1_0.stderr  |  35 +-
 testsuite/tests/generics/GenDerivOutput1_1.stderr  | 264 +++++++-------
 .../tests/generics/T10604/T10604_deriving.stderr   | 253 +++++++------
 testsuite/tests/perf/compiler/T5642.hs             | 402 +++++++++++----------
 testsuite/tests/perf/compiler/all.T                |   5 +-
 testsuite/tests/perf/haddock/all.T                 |   3 +-
 8 files changed, 651 insertions(+), 538 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 9649fc0ae45e006c2ed54cc5ea2414158949fadb


More information about the ghc-commits mailing list