Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,334
    • Issues 4,334
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 369
    • Merge Requests 369
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Merge Requests
  • !1866

Open
Opened Oct 03, 2019 by Sebastian Graf@sgraf812Developer
  • Report abuse
Report abuse

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b "wip/nested-cpr-2019" "origin/wip/nested-cpr-2019"

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout "master"
git merge --no-ff "wip/nested-cpr-2019"

Step 4. Push the result of the merge to GitLab

git push origin "master"

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

Nested CPR Analysis (#18174)

  • Overview 106
  • Commits 3
  • Pipelines 84
  • Changes 108

Nested CPR analysis (#18174)

This MR extends CPR analysis to unbox nested constructors. See Note [Nested CPR] for examples.

Unboxing a function's result beyond the first level risks making the function more strict, rendering the transformation unsound. See Note [Nested CPR needs Termination information]. To justify unboxing anyway, Nested CPR interleaves a termination analysis that is like a higher-order exprOkForSpeculation.

The termination analysis makes for the bulk of complexity in this patch. In principle, we can use the results of that analysis in many more ways in the future to do speculative execution.

Although there are quite a few examples in test cases that are now properly optimised (e.g., T1600, T18174, T18894), the results on NoFib are meager:

--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
      cacheprof          -0.3%     -1.4%
      compress2          -1.9%     -0.9%
 fannkuch-redux           0.0%     -1.3%
         gamteb          -1.6%     -0.3%
       nucleic2          -1.2%     -0.6%
          sched          -0.0%     +0.9%
           x2n1          -0.0%     -5.0%
--------------------------------------------------------------------------------
            Min          -1.9%     -5.0%
            Max          +0.1%     +0.9%
 Geometric Mean          -0.1%     -0.1%

Allocation while compiling NoFib increases by 0.5%. Binary sizes on NoFib increase by 0.7%.

This patch manages to fix a few tickets: Fixes #1600, #18174, #18109

ghc/alloc performance generally increases. run/alloc metrics improve throughout.

Justifications for metric increases:

  • MultiLayerModules increases due to #19293.
  • I could reproduce the 2.5% increase on T13701 on fedora in a -O0 perf-flavoured build. With -fno-code or -O2 this patch is faster. I investigated -v2 output, nothing obvious. It's very similar to #19293, so I'm just going to accept it.
  • The +15% ghc/alloc increase on T15164 in a registerised, validate-flavoured build does not show up under -dshow-passes and has no impact on runtime. #19311
  • I verified that T13253 simply does one more round of Simplification after Nested CPR
  • I looked at heap profiles for the ghc/max_bytes_used increases, which didn't show any obvious offenders.
Edited Feb 04, 2021 by Sebastian Graf
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
Reference: ghc/ghc!1866
Source branch: wip/nested-cpr-2019