An impressive macrobenchmark for eio

While wandering around the web I came across a link to a slide deck by our own @kayceesrk. On slide #35 is a macrobenchmark showing an EIO-based network server, and its throughput is pretty favorable compared to the Rust implementation’s.

Taking this at face value, it seems like quite an achievement - not only because GC is (supposedly) a handicap for OCaml, but also because this seems like a major improvement over a similar benchmark from 2022. I couldn’t find links to deeper discussion of these results, so I thought I would ask some of the obvious follow-up questions:

  • Is OCaml’s tail latency on par with Rust’s in these scenarios?
  • Are both the “OCaml eio” and “Rust Hyper” results using similar kernel capabilities, e.g. io_uring? (The slide seems to suggest so, but just confirming.)
  • Do these results generalize to different levels of concurrency, request/response sizes, etc?

Either way, kudos for raising OCaml’s profile as a platform for scalable computing!

3 Likes

They both used io_uring, yes. The OCaml bindings are at GitHub - ocaml-multicore/ocaml-uring: Bindings to io_uring for OCaml ; but note that there are several levels of io_uring usage possible depending on your tolerance for ranges of Linux kernel support (I’m just adding zero-copy transmit support at the moment for a project involving a petabyte of data).

OCaml’s tail latency will be worse than Rust’s due to having a GC, but not terribly so. As for generalization, those tests were run on a pre-5.0 version of OCaml, so the whole test suite would have to be rebased against the released versions. A good and useful exercise if someone would like to have a go at it!

5 Likes

I think the benchmarks are from GitHub - ocaml-multicore/retro-httpaf-bench: Benchmarking environment for http servers

I don’t think the Rust ones are using uring, but I’m not sure. I suspect that all the non-OCaml ones could do with a fan of that language optimising them a bit.

In my experience, whether the Rust or Eio version gets better throughput depends on e.g. the number of connections, and tail latency was always better with Rust.

But the basic result is that OCaml is competitive with Rust here.

4 Likes

Rust hyper (and most Rust web servers) do not use io_uring.

2 Likes