I never heard of this runtime before, but this is totally insane! Never before have I thought that a JavaScript runtime can get this fast, AND it can interoperate with any language that GraalVM supports! I’ll do some (probably unscientific) benchmarks of my Project Euler code (I’ve been stumped on speeding up a few of the algorithms) and report back with the results soon.
This project to run Purescript natively on Graal seems very interesting but long abandoned. Has anyone tried to get it working again? I wonder what the performance would be like.
I’ve long wanted to get a proper GraalVM interpreter working, going so far as to write codecs and folds for CoreFn data types in Java, but never found the time or energy to see it through. I think it would have a lot of potential.
The Haskell server is sending more headers. It shouldn’t make a lot of difference to the numbers though.
I appreciate the intent here; but I don’t know that that’s true; for a “hello world” server the processing is effectively a no-op; so it’s likely that the performance is IO bound, which would imply that tripling the number of bytes (154 chars for WAI, 50 chars for ES4X) is definitely relevant.
The 120,000 req/sec is impressive on its own, so be proud of that; but I do take issue with the implication that it’s “faster” than WAI when ES4X doing approx. 1/3rd of the work that WAI is
In any real workload these extra headers most likely amortize away into nothing; but in a micro-benchmark they’re important. Just another argument against micro-benchmarks I suppose
Well I’d have more reason to be proud of Haskell’s perf since I wrote the Haskell web framework I used for the benchmark, whereas purescript-es4x is only a small shim over es4x itself!
This is more about having a JS runtime be fast at all and having atleast comparable performance to compiled Haskell.
Just to have a bit more fair comparison, I added a bunch of text to the response from ES4X -
I wonder how far one can add type safety while keeping things simple and without completely changing the API. Got here then ran out of time. I need to take a look at the other server frameworks for their solutions.
main :: Effect Unit
main = do
router <- createRouter
runApp do
stringHandler router "/" \req -> do
pure "Hello String"
templateHandler router "/fortunes" \req -> do
pure $ Template "templates/fortunes.hbs" { fortunes: [{ id: 1, message: "Hello Template" }] }
jsonHandler router "/json" \req -> do
pure { bananas: [1, 2, 3] }
stringHandler router "/wait" \_ -> do
liftAff $ delay $ Milliseconds 5000.0
Config { port } <- ask
pure $ "Waited on port " <> show port
runHttpServer router