Skip to content
This repository

Too much inlining #19

Closed
snoyberg opened this Issue March 18, 2012 · 7 comments

6 participants

Michael Snoyman Bryan O'Sullivan Aleksey Khudyakov Johan Tibell Jared Hance Felipe Lessa
Michael Snoyman

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

See Felipe's post to the cafe for more details: http://www.haskell.org/pipermail/haskell-cafe/2012-March/100162.html

Michael Snoyman snoyberg referenced this issue in yesodweb/yesod March 20, 2012
Closed

Too much inlining in Shakespeare? #298

Aleksey Khudyakov

One of problems is that literals produce too much code.

text :: T.Text
text = T.pack "text"
  Data.Text.Fusion.unstream
    (Data.Text.Fusion.Common.streamList
       @ GHC.Types.Char
       (GHC.Base.map
          @ GHC.Types.Char
          @ GHC.Types.Char
          Data.Text.Internal.safe
          (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
Johan Tibell
tibbe commented March 23, 2012

There used to be such a rule for ByteStrings, but it stopped working not too long ago. See this ticket: http://hackage.haskell.org/trac/ghc/ticket/5218

Jared Hance

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.

Bryan O'Sullivan
Owner
bos commented April 07, 2012

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

Bryan O'Sullivan
Owner
bos commented April 07, 2012

Tagged and released from 6f64406.

Bryan O'Sullivan bos closed this April 07, 2012
Felipe Lessa

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.

Michael Snoyman snoyberg referenced this issue from a commit in yesodweb/shakespeare April 08, 2012
Michael Snoyman Conditionally turn off NOINLINE fix (bos/text#19) d23497b
Michael Snoyman snoyberg referenced this issue from a commit in yesodweb/persistent April 08, 2012
Michael Snoyman Conditionally turn off NOINLINE fix (bos/text#19) 5b2cc67
Michael Snoyman

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.