Skip to content
  • Simon Peyton Jones's avatar
    Do not unpack class dictionaries with INLINABLE · 3d38e828
    Simon Peyton Jones authored
    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.
    3d38e828