Investigate Lexer performance
Going through the ticky profile for the testcase MultiLayerModules
, I noticed that there are 380k calls to GHC.Parser.Lexer.lexToken
, for a total of 267MB allocations. That's 700 bytes per lexer call! There were also 2M calls to $walexGetByte
, contributing 293MB of allocations. So almost 100 bytes allocated for every byte "got".
We should investigate if there's a quick win.
I think sum CPR (#14259) would get rid of some allocation in $walexGetByte
. It's a perfectly constructed sum where all fields terminate because of seq
s. Of course, we could also do the transformation manually...