[GHC] #16190: Speed up handling of large String literals

GHC ghc-devs at haskell.org
Fri Jan 18 02:28:23 UTC 2019


#16190: Speed up handling of large String literals
-------------------------------------+-------------------------------------
        Reporter:  hsyl20            |                Owner:  (none)
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by hsyl20):

 New approach: instead of messing with Core, we only add the optimization
 into the NCG. For large strings, instead of printing `.asciz "..."` we
 print `.incbin "tmpfileXXX.dat"` and we dump the contents of the string
 into "tmpfileXXX.dat".

 This relies on the patch for #16198 so that we benefit from ByteStrings
 for string literals down to the NCG.

 I have updated the branch:
 https://gitlab.haskell.org/hsyl20/ghc/tree/hsyl20-T16190

 This new approach works very well even with TH generated string literals.
 The following table shows the time to compile a source that uses `file-
 embed` with different file sizes. I have set the threshold to 500k for the
 test and as the default value in the patch (hence the optimization is not
 triggered for the 4 first file sizes).

 || Size || 8.6.3   || HEAD + #16198   || HEAD + #16198 + Threshold 500K
 || Gain ||
 || 128  || 2.650   || 2.331    || 2.346        || (-0.5%)   ||
 || 3K   || 2.651   || 2.289    || 2.290        || (0%)   ||
 || 30K  || 2.590   || 2.353    || 2.307        || (+2%)  ||
 || 100K || 2.717   || 2.379    || 2.389        || (0%)  ||
 || 500K || 3.621   || 2.814    || 2.331        || +17%  ||
 || 1M   || 4.694   || 3.526    || 2.654        || +24% ||
 || 2M   || 6.784   || 4.668    || 2.650        || +21% ||
 || 3M   || 8.851   || 5.616    || 3.073        || +45% ||
 || 30M  || 63.181  || 34.318   || 8.517        || +75% ||

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16190#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list