[commit: ghc] ghc-8.0: Refactor derived Generic instances to reduce allocations (1c31013)

git at git.haskell.org git at git.haskell.org
Wed Aug 24 23:14:53 UTC 2016


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

On branch  : ghc-8.0
Link       : http://ghc.haskell.org/trac/ghc/changeset/1c310133bbea168356e86aa38771f0da0d1315af/ghc

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

commit 1c310133bbea168356e86aa38771f0da0d1315af
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
    
    (cherry picked from commit 9649fc0ae45e006c2ed54cc5ea2414158949fadb)


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

1c310133bbea168356e86aa38771f0da0d1315af
 compiler/typecheck/TcGenGenerics.hs               | 112 +++++-
 testsuite/tests/generics/GenDerivOutput.stderr    | 144 ++++----
 testsuite/tests/generics/GenDerivOutput1_0.stderr |  35 +-
 testsuite/tests/generics/GenDerivOutput1_1.stderr | 264 +++++++-------
 testsuite/tests/perf/compiler/T5642.hs            | 402 +++++++++++-----------
 testsuite/tests/perf/compiler/all.T               |   3 +-
 6 files changed, 538 insertions(+), 422 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 1c310133bbea168356e86aa38771f0da0d1315af


More information about the ghc-commits mailing list