[Haskell-cafe] Happstack: serveDirectory vs serveFile

Semen Trygubenko / Семен Тригубенко semen at trygub.com
Sat Jan 24 01:10:38 UTC 2015


Hi Jeremy,

Thanks for your reply. I have not found the cause of this issue,
but I know now it is not related to happstack after all.

On Fri, Jan 23, 2015 at 04:46:09PM -0600, Jeremy Shaw wrote:
> The first thing to double check is that both serveDirectory and serveFile
> are returning 200 OK, and not 404. You want to confirm that the file really
> is being transferred in both cases.

Confirmed.


> Since serveDirectory is listed first, it is going to have a slight
> advantage, because the routes are tried in order. If you switch the order
> and list serveFile first do you see any change in performance?

I tried that before with no luck.


> Additionally, in this code you could get away with using 'dir' instead of
> 'dirs' since you do not have any '/' in the path. Because 'dirs' has to
> look for the '/', it is going to take longer to search 'favicon.ico' than
> 'hehe' -- which would also give a slightly advantage to the serveDirectory
> branch.

Previously it contained a '/', but it no longer does,
so I've changed it now. Thanks for the tip!


> But microbenchmarks like
> this can easily be dominated by unrelated factors.

Yes, sadly, I've done this benchmark from behind apache.
I should have benchmarked happstack in isolation before posting, but previously the results
correlated very well... After some experimentation I have
found that this pathological behaviour is observed when file is small
and going via apache on that route. When file
size goes over 1-2kb it starts to fly but for some reason serving tiny files
under 1kb is dog slow. When talking to happstack direct
results are sane.

Thanks for your help, and sorry for starting to dig in the wrong direction...
S.


-- 
Семен Тригубенко http://trygub.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20150124/7456ccbe/attachment.sig>


More information about the Haskell-Cafe mailing list