Skip to content

Enhance pretty-printing perf

Sylvain Henry requested to merge hsyl20/ghc:hsyl20/perf/pprinline into master

A few refactorings made after looking at Core/STG

* Use Doc instead of SDoc in pprASCII to avoid passing the SDocContext
  that is never used.

* Inline every SDoc wrappers in GHC.Utils.Outputable to expose Doc
  constructs

* Add text/[] rule for empty strings (i.e., text "")

* Use a single occurrence of pprGNUSectionHeader

* Use bangs on Platform parameters and some others

Performance results on CI are good:

All baseline commits are df8e8ba267
Metrics: compile_time/bytes allocated
-------------------------------------
                                         Baseline
                     Test    Metric         value     New value Change
---------------------------------------------------------------------------
 ManyAlternatives(normal) ghc/alloc   813795108.0   806305320.0  -0.9%
 ManyConstructors(normal) ghc/alloc  4410899024.0  4386483736.0  -0.6%
MultiLayerModules(normal) ghc/alloc  6002819372.0  6001120832.0  -0.0%
         Naperian(optasm) ghc/alloc    56988480.0    56930584.0  -0.1%
        PmSeriesG(normal) ghc/alloc    54410200.0    54066640.0  -0.6%
        PmSeriesS(normal) ghc/alloc    68737324.0    68022688.0  -1.0%
        PmSeriesT(normal) ghc/alloc   100702060.0    99432024.0  -1.3%
        PmSeriesV(normal) ghc/alloc    67763984.0    67079520.0  -1.0%
           T10421(normal) ghc/alloc   128378940.0   127442088.0  -0.7%
          T10421a(normal) ghc/alloc    90724404.0    89998720.0  -0.8%
           T10547(normal) ghc/alloc    32959212.0    32861752.0  -0.3%
           T10858(normal) ghc/alloc   206706676.0   203014936.0  -1.8%
           T11195(normal) ghc/alloc   302380516.0   297810856.0  -1.5%
           T11276(normal) ghc/alloc   151074228.0   148749328.0  -1.5%
          T11303b(normal) ghc/alloc    50758884.0    50286024.0  -0.9%
           T11374(normal) ghc/alloc   273249100.0   267774608.0  -2.0%
           T11822(normal) ghc/alloc   148291112.0   146113128.0  -1.5%
           T12150(optasm) ghc/alloc    91723796.0    91365264.0  -0.4%
           T12227(normal) ghc/alloc   494280872.0   493015512.0  -0.3%
           T12234(optasm) ghc/alloc    65527096.0    65061232.0  -0.7%
           T12425(optasm) ghc/alloc   111142076.0   110302984.0  -0.8%
           T12545(normal) ghc/alloc  1796480164.0  1790113672.0  -0.4%
           T12707(normal) ghc/alloc  1054042212.0  1033408000.0  -2.0% GOOD
           T13035(normal) ghc/alloc   113876312.0   112940192.0  -0.8%
           T13056(optasm) ghc/alloc   392968164.0   389973968.0  -0.8%
           T13253(normal) ghc/alloc   380540528.0   377406816.0  -0.8%
       T13253-spj(normal) ghc/alloc   168105912.0   166598592.0  -0.9%
           T13379(normal) ghc/alloc   400347080.0   391662192.0  -2.2% GOOD
           T13701(normal) ghc/alloc  2533741756.0  2531392880.0  -0.1%
           T13719(normal) ghc/alloc  4664088528.0  4656396360.0  -0.2%
             T14052(ghci) ghc/alloc  2190161320.0  2177025864.0  -0.6%
           T14683(normal) ghc/alloc  3101664608.0  3091329296.0  -0.3%
           T14697(normal) ghc/alloc   373782428.0   373304720.0  -0.1%
           T15164(normal) ghc/alloc  1526380188.0  1515234448.0  -0.7%
           T15630(normal) ghc/alloc   189545220.0   188106456.0  -0.8%
           T16190(normal) ghc/alloc   287212988.0   286823488.0  -0.1%
           T16577(normal) ghc/alloc  8302473852.0  8239170568.0  -0.8%
           T17096(normal) ghc/alloc   314814756.0   309013688.0  -1.8%
           T17516(normal) ghc/alloc  1325413848.0  1310505352.0  -1.1%
           T17836(normal) ghc/alloc  1177216952.0  1166756408.0  -0.9%
          T17836b(normal) ghc/alloc    58723776.0    58219008.0  -0.9%
           T17977(normal) ghc/alloc    51474192.0    50977424.0  -1.0%
          T17977b(normal) ghc/alloc    46317220.0    45903216.0  -0.9%
           T18140(normal) ghc/alloc   115947152.0   114888888.0  -0.9%
           T18223(normal) ghc/alloc  5595508252.0  5591348496.0  -0.1%
           T18282(normal) ghc/alloc   164698576.0   163304272.0  -0.8%
           T18304(normal) ghc/alloc   104589052.0   103870416.0  -0.7%
           T18478(normal) ghc/alloc   811595676.0   797393504.0  -1.7%
          T18698a(normal) ghc/alloc   436690144.0   428335360.0  -1.9% GOOD
          T18698b(normal) ghc/alloc   526957432.0   516971488.0  -1.9% GOOD
           T18923(normal) ghc/alloc    77039624.0    76367584.0  -0.9%
            T1969(normal) ghc/alloc   844073600.0   824437176.0  -2.3% GOOD
            T3064(normal) ghc/alloc   208739728.0   207062816.0  -0.8%
            T3294(normal) ghc/alloc  1783828240.0  1710288080.0  -4.1% GOOD
            T4801(normal) ghc/alloc   337522812.0   330549296.0  -2.1% GOOD
            T5030(normal) ghc/alloc   375621816.0   374459184.0  -0.3%
          T5321FD(normal) ghc/alloc   304088916.0   299251312.0  -1.6%
         T5321Fun(normal) ghc/alloc   348122984.0   343333008.0  -1.4%
            T5631(normal) ghc/alloc   627309068.0   624805208.0  -0.4%
            T5642(normal) ghc/alloc   538284348.0   534862088.0  -0.6%
            T5837(normal) ghc/alloc    41769152.0    41558040.0  -0.5%
            T6048(optasm) ghc/alloc    92676444.0    91845744.0  -0.9%
             T783(normal) ghc/alloc   427918864.0   420979208.0  -1.6%
            T9020(optasm) ghc/alloc   274757696.0   274091424.0  -0.2%
            T9233(normal) ghc/alloc   964540428.0   962116504.0  -0.3%
            T9630(normal) ghc/alloc  1567187716.0  1560343360.0  -0.4%
            T9675(optasm) ghc/alloc   592132884.0   590958144.0  -0.2%
           T9872a(normal) ghc/alloc  1851256124.0  1851152368.0  -0.0%
           T9872b(normal) ghc/alloc  2385271132.0  2385201176.0  -0.0%
           T9872c(normal) ghc/alloc  1891277620.0  1891183232.0  -0.0%
           T9872d(normal) ghc/alloc   578259852.0   577770472.0  -0.1%
            T9961(normal) ghc/alloc   400283520.0   398379760.0  -0.5%
            WWRec(normal) ghc/alloc   810762276.0   805093408.0  -0.7%
           hie002(normal) ghc/alloc  9818572420.0  9818791760.0  +0.0%
       parsing001(normal) ghc/alloc   493912352.0   493846992.0  -0.0%

Merge request reports