[Haskell-beginners] Warp and Yesod benchmark puzzle

Lorenzo Bolla lbolla at gmail.com
Sat Sep 1 16:55:38 CEST 2012


On Sat, Sep 01, 2012 at 11:20:06AM -0300, Felipe Almeida Lessa wrote:
> On Sat, Sep 1, 2012 at 6:33 AM, Krzysztof Skrzętnicki <gtener at gmail.com> wrote:
> > makeSessionBackend calls "getKey" from clientsession:
> >
> > http://hackage.haskell.org/packages/archive/clientsession/0.8.0/doc/html/src/Web-ClientSession.html#getKey
> >
> > Looking at that function no wonder it is a bottleneck:
> >
> > -- | Get a key from the given text file.
> > --
> > -- If the file does not exist or is corrupted a random key will
> > -- be generated and stored in that file.
> > getKey :: FilePath     -- ^ File name where key is stored.
> >        -> IO Key       -- ^ The actual key.
> > getKey keyFile = do
> >     exists <- doesFileExist keyFile
> >     if exists
> >         then S.readFile keyFile >>= either (const newKey) return . initKey
> >         else newKey
> >   where
> >     newKey = do
> >         (bs, key') <- randomKey
> >         S.writeFile keyFile bs
> >         return key'
> >
> >
> > Plenty of syscalls, reading and parsing the same file over and over again.
> > Perhaps the default should be to store the key within the foundation
> > datatype at startup?
> 
> Unfortunately it's not so simple: makeSessionBackend is called just
> once by 'toWaiAppPlain', which is in turn called just once when your
> application starts.
> 
> Cheers, =)
> 
> -- 
> Felipe.

I wonder if the problem is rather the `decrypt`ion of the _SESSION cookie at
each request, in which case the bottleneck is the encryption library (AES?).

L.


-- 
Lorenzo Bolla
http://lbolla.info



More information about the Beginners mailing list