Do not unpack class dictionaries with INLINABLE
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 26 Apr 2018 14:59:13 +0000 (15:59 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 26 Apr 2018 16:44:02 +0000 (17:44 +0100)
commit3d38e8284b7382844f9862e8d8afbae9c7248b09
treebfb23aa121d7a0192f2a73874b0796767e88d6d7
parent625eea9332532666a35b4cc680ef4f7e51d4b2d1
Do not unpack class dictionaries with INLINABLE

Matthew Pickering uncovered a bad performance hole in the way
that single-method dictionaries work, described in Trac #14955.

See Note [Do not unpack class dictionaries] in WwLib.

I tried to fix this 6 years ago, but got it slightly wrong.  This patch
fixes it, which makes a dramatic improvement in the test case.

Nofib highlights: not much happening:

  Program           Size    Allocs   Runtime   Elapsed  TotalMem
-----------------------------------------------------------------
      VSM          -0.3%     +2.7%     -7.4%     -7.4%      0.0%
cacheprof          -0.0%     +0.1%     +0.3%     +0.7%      0.0%
  integer          -0.0%     +1.1%     +7.5%     +7.5%      0.0%
      tak          -0.1%     -0.2%     0.024     0.024      0.0%
-----------------------------------------------------------------
      Min          -4.4%     -0.2%     -7.4%     -7.4%     -8.0%
      Max          +0.6%     +2.7%     +7.5%     +7.5%      0.0%
Geom Mean          -0.1%     +0.0%     +0.1%     +0.1%     -0.2%

I investigated VSM.  The patch unpacks class dictionaries a bit more
than before (i.e. does so if there is no INLINABLE pragma). And that
gives better code in VSM (less dictionary selection etc), but one closure
gets one word bigger.

I'll accept these changes in exchange for more robust performance.

Some ghci.debugger output wobbled around (order of bindings
being displayed). I have no idea why; but I accepted the changes.
compiler/stranal/WorkWrap.hs
compiler/stranal/WwLib.hs
testsuite/tests/ghci.debugger/scripts/break006.stdout
testsuite/tests/ghci.debugger/scripts/hist001.stdout
testsuite/tests/ghci.debugger/scripts/hist002.stdout
testsuite/tests/indexed-types/should_compile/T7837.stderr
testsuite/tests/perf/should_run/T14955.hs [new file with mode: 0644]
testsuite/tests/perf/should_run/T14955.stdout [new file with mode: 0644]
testsuite/tests/perf/should_run/T14955a.hs [new file with mode: 0644]
testsuite/tests/perf/should_run/all.T