Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
Source project has a limited visibility.
  • Ben Gamari's avatar
    f7ede672
    Specialise: Avoid unnecessary recomputation of free variable information · f7ede672
    Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
    When examining compile times for code with large ADTs (particularly those with
    many record constructors), I found that the specialiser contributed
    disproportionately to the compiler runtime. Some profiling suggested that
    the a great deal of time was being spent in `pair_fvs` being called from
    `consDictBind`.
    
    @simonpj pointed out that `flattenDictBinds` as called by `specBind` was
    unnecessarily discarding cached free variable information, which then needed to
    be recomputed by `pair_fvs`.
    
    Here I refactor the specializer to retain the free variable cache whenever
    possible.
    
    **Open Qustions**
    
     * I used `fst` in a couple of places to extract the bindings from a `DictBind`.
       Perhaps this is a sign that `DictBind` has outgrown its type synonym status?
    
    Test Plan: validate
    
    Reviewers: austin, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: thomie, bgamari, simonpj
    
    Differential Revision: https://phabricator.haskell.org/D1012
    
    GHC Trac Issues: #7450
    f7ede672
    History
    Specialise: Avoid unnecessary recomputation of free variable information
    Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
    When examining compile times for code with large ADTs (particularly those with
    many record constructors), I found that the specialiser contributed
    disproportionately to the compiler runtime. Some profiling suggested that
    the a great deal of time was being spent in `pair_fvs` being called from
    `consDictBind`.
    
    @simonpj pointed out that `flattenDictBinds` as called by `specBind` was
    unnecessarily discarding cached free variable information, which then needed to
    be recomputed by `pair_fvs`.
    
    Here I refactor the specializer to retain the free variable cache whenever
    possible.
    
    **Open Qustions**
    
     * I used `fst` in a couple of places to extract the bindings from a `DictBind`.
       Perhaps this is a sign that `DictBind` has outgrown its type synonym status?
    
    Test Plan: validate
    
    Reviewers: austin, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: thomie, bgamari, simonpj
    
    Differential Revision: https://phabricator.haskell.org/D1012
    
    GHC Trac Issues: #7450
Code owners
Assign users and groups as approvers for specific file changes. Learn more.