Too much inlining #19

snoyberg opened this Issue Mar 18, 2012 · 7 comments


None yet

6 participants


tl;dr: text package's pack function is creating huge chunks of code everywhere.

See Felipe's post to the cafe for more details:

@snoyberg snoyberg referenced this issue in yesodweb/yesod Mar 20, 2012

Too much inlining in Shakespeare? #298


One of problems is that literals produce too much code.

text :: T.Text
text = T.pack "text"
       @ GHC.Types.Char
          @ GHC.Types.Char
          @ GHC.Types.Char

          (GHC.Base.unpackCString# "text")))

I think it could be solved with rewrite rule like that. It should be faster since it avoids lists creation and will produce way less code.

textLiteral :: Addr# → Text
textLiteral = ...

unstream (streamList (map safe (unpackCString# s))) → textLiteral
tibbe commented Mar 23, 2012

There used to be such a rule for ByteStrings, but it stopped working not too long ago. See this ticket:

jhance commented Apr 4, 2012

When GHC generates code for anything with non-ASCII characters, it uses unpackCStringUtf8#. It would be really nice if it used unpackCStringUtf8Len# though...

Working on a patch.

@bos bos was assigned Apr 8, 2012
bos commented Apr 8, 2012

I've fixed this in 2b2cb08. Working on backports to older versions of GHC now :-(

bos commented Apr 8, 2012

Tagged and released from 6f64406.

@bos bos closed this Apr 8, 2012

Thanks a lot, @bos!

@snoyberg, we should remove those NOINLINE pack wrappers when building with the fixed text package in order to avoid converting from String every time.

@snoyberg snoyberg added a commit to yesodweb/shakespeare that referenced this issue Apr 8, 2012
@snoyberg snoyberg Conditionally turn off NOINLINE fix (bos/text#19) d23497b
@snoyberg snoyberg added a commit to yesodweb/persistent that referenced this issue Apr 8, 2012
@snoyberg snoyberg Conditionally turn off NOINLINE fix (bos/text#19) 5b2cc67
snoyberg commented Apr 8, 2012

@meteficha Agreed, and done. It will be part of the 1.0 release. And I'll have the yesod-platform point to version of text. Thanks again @bos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment