bos/base64-bytestring — Issue #4: Massive performance slowdown in 0.1.1.0
Author: snoyberg
Created: 2012-02-28 10:18:18+00:00
State: open

Hi Bryan,

I got a report from Kirill of a massive performance problem in Yesod.
If sessions were turned on, on my system, req/sec went from 6000 to
200. I checked clientsession, and found it to be the culprit: encoding
a minimal payload requires a few milliseconds. Felipe checked the
recent changes, and localized it to the most recent release of
base64-bytestring. I put together a simple benchmark:

import Data.ByteString.Base64
import Data.ByteString.Char8 (pack)
import Criterion.Main

main :: IO ()
main = defaultMain
[ bench "encode" $ whnf encode $ pack "qwerty"
]

On version 0.1.0.3, this takes 229.4312 ns. On 0.1.1.0, it takes
3.556598 ms. It looks like the problem is coming from the recent
addition of URL encoding
(f1916d8a86b496cfacd23939b5e3fa10d92abb7b).

As a temporary workaround, I'm planning on adding an upper bound on
the base64-bytestring dependency in clientsession, so we shouldn't
have any immediate issues, but obviously it would be best if we didn't
have to put restrictive upper bounds in.

Thanks,
Michael