Optimize dumping of consecutive whitespace.
The naive way of putting out n characters of indent would be something like `hPutStr hdl (replicate n ' ')`. However this is quite inefficient as we allocate an absurd number of strings consisting of simply spaces as we don't cache them. To improve on this we now track if we can simply write ascii spaces via hPutBuf instead. This is the case when running with -ddump-to-file where we force the encoding to be UTF8. This avoids both the cost of going through encoding as well as avoiding allocation churn from all the white space. Instead we simply use hPutBuf on a preallocated unlifted string. When dumping stg like this: > nofib/spectral/simple/Main.hs -fforce-recomp -ddump-stg-final -ddump-to-file -c +RTS -s Allocations went from 1,778 MB to 1,702MB. About a 4% reduction of allocation! I did not measure the difference in runtime but expect it to be similar. Bumps the haddock submodule since the interface of GHC's Pretty slightly changed.
parent
fc644b1a
No related branches found
No related tags found
Pipeline #27871 failed
Stage: tool-lint
Stage: quick-build
Stage: lint
Stage: build
Stage: full-build
Stage: packaging
Stage: testing
Showing
- compiler/GHC/Driver/Ppr.hs 1 addition, 1 deletioncompiler/GHC/Driver/Ppr.hs
- compiler/GHC/Driver/Session.hs 15 additions, 12 deletionscompiler/GHC/Driver/Session.hs
- compiler/GHC/Utils/Error.hs 2 additions, 1 deletioncompiler/GHC/Utils/Error.hs
- compiler/GHC/Utils/Outputable.hs 1 addition, 1 deletioncompiler/GHC/Utils/Outputable.hs
- compiler/GHC/Utils/Ppr.hs 46 additions, 4 deletionscompiler/GHC/Utils/Ppr.hs
- utils/haddock 1 addition, 1 deletionutils/haddock
Loading
Please register or sign in to comment