haskell webframeworks speed, GHCi vs Compiled

281 views Asked by At

Today I did little benchmarking on my local machine to compare plain text speed of different Haskell web frameworks, and I noticed something strange. Almost all the frameworks that I tested, performed better when they were run from GHCi compared to compiled version. here are my results

+------------------------------------
|framework| GHCi rpm   | compiled rpm 
+---------+------------+-------------
|snap     | 8000       | 150
+---------+------------+-------------
|yesod    | 6000       | 2500
+---------+------------+-------------
|scotty   | 22000      | 9500
+---------+------------+-------------
|servant  | 17000      | 8500
+---------+------------+-------------
|spock    | 3300       | 2700
+---------+------------+-------------

I know that these numbers do not reflect on these frameworks speed, since they are not well tuned or optimized, but my question is why are these frameworks performing better when launched from GHCi. Am I doing something wrong ?

in order to build them I simply run stack build

1

There are 1 answers

1
Sibi On

This was a recent issue found out by Harendra Kumar also in this GHC ticket. You can see the relevant ghc-dev mailing list discussion here. See this specific observation from Harendra:

While trying to come up with a minimal example I discovered one more puzzling thing. runghc is fastest, ghc is slower, ghc with optimization is slowest. This is completely reverse of the expected order.

If possible, I would suggest you to come up with a minimal benchmark for the same and update the ghc ticket with your repository.