Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
Source project has a limited visibility.
  • Andreas Klebinger's avatar
    09c1d5af
    Replace most occurences of foldl with foldl'. · 09c1d5af
    Andreas Klebinger authored
    This patch adds foldl' to GhcPrelude and changes must occurences
    of foldl to foldl'. This leads to better performance especially
    for quick builds where GHC does not perform strictness analysis.
    
    It does change strictness behaviour when we use foldl' to turn
    a argument list into function applications. But this is only a
    drawback if code looks ONLY at the last argument but not at the first.
    And as the benchmarks show leads to fewer allocations in practice
    at O2.
    
    Compiler performance for Nofib:
    
    O2 Allocations:
            -1 s.d.                -----            -0.0%
            +1 s.d.                -----            -0.0%
            Average                -----            -0.0%
    
    O2 Compile Time:
            -1 s.d.                -----            -2.8%
            +1 s.d.                -----            +1.3%
            Average                -----            -0.8%
    
    O0 Allocations:
            -1 s.d.                -----            -0.2%
            +1 s.d.                -----            -0.1%
            Average                -----            -0.2%
    
    Test Plan: ci
    
    Reviewers: goldfire, bgamari, simonmar, tdammers, monoidal
    
    Reviewed By: bgamari, monoidal
    
    Subscribers: tdammers, rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4929
    09c1d5af
    History
    Replace most occurences of foldl with foldl'.
    Andreas Klebinger authored
    This patch adds foldl' to GhcPrelude and changes must occurences
    of foldl to foldl'. This leads to better performance especially
    for quick builds where GHC does not perform strictness analysis.
    
    It does change strictness behaviour when we use foldl' to turn
    a argument list into function applications. But this is only a
    drawback if code looks ONLY at the last argument but not at the first.
    And as the benchmarks show leads to fewer allocations in practice
    at O2.
    
    Compiler performance for Nofib:
    
    O2 Allocations:
            -1 s.d.                -----            -0.0%
            +1 s.d.                -----            -0.0%
            Average                -----            -0.0%
    
    O2 Compile Time:
            -1 s.d.                -----            -2.8%
            +1 s.d.                -----            +1.3%
            Average                -----            -0.8%
    
    O0 Allocations:
            -1 s.d.                -----            -0.2%
            +1 s.d.                -----            -0.1%
            Average                -----            -0.2%
    
    Test Plan: ci
    
    Reviewers: goldfire, bgamari, simonmar, tdammers, monoidal
    
    Reviewed By: bgamari, monoidal
    
    Subscribers: tdammers, rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4929
Code owners
Assign users and groups as approvers for specific file changes. Learn more.