Thomas Leonard's work notes

(see roscidus.com for my main blog)

(off-site, socket options, fifos)

I spent a few pleasant days meeting people at the Tarides off-site near Paris. Apart from that, I've been continuing to review and finish Eio PRs.

Eio

We've wanted support for setting socket options in Eio for ages, and I finally got around to reviewing Anil's PR adding them. It was pretty big, so I split parts of it off into two smaller PRs and reviewed them separately (it's all merged now):

  • Initial support for setting/getting socket options #858.
  • Add portable names for common network options #859.
  • eio_linux: Add Linux-specific socket options #575.

wayland-proxy-virtwl uses a FIFO (named piped) to accept debug commands (asking it to dump the log ring to a file). I'd noticed a while ago that it would spin using 100% CPU when run with EIO_BACKEND=posix and finally got around to investigating:

  • eio_posix: fifos don't work properly #856.

In summary, opening a FIFO for reading normally waits for a writer to connect, but in a concurrent application that would stop the whole program. To fix that, we open them in non-blocking mode. But that has a wierd behaviour: trying to read from the pipe immediately returns end-of-file rather than EAGAIN, even though select says that it's not ready!

  • eio_posix: wait for a writer when first reading from a FIFO #857.

Other reviewed PRs:

  • Propagate errno back from fork_actions into Eio.Process #854.
    This allows handling specific errors, rather than just getting a generic Failure with a string.

  • Support chmod in Eio_linux and Eio_posix #785.
    Another of Patrick's PRs adding missing Unix functionality to Eio.

  • Relax return types of Eio.Process.Pipe #775.
    This was an Outreachy PR that got abandoned in 2024; finishing it off was a quick job.

dune pkg

Talking with Shon Feder at the Tarides off-site reminded me I should try out OCaml Package Management With Dune. To build an OCaml program you normally first run opam install --deps-only -t . to get the dependencies and then dune build to build it, but you can have dune get the required packages too by using dune build --pkg=enable. It's still experimental, but looks promising. Some things I noticed:

  • Dune's progress indicator isn't really designed for long build times, such as downloading and building the OCaml compiler. It could do with showing more information.

  • It doesn't seem to support installing depexts (non-OCaml dependencies) yet, although it can tell you what they are.

  • But default it doesn't use a shared cache, so if you build two projects this way it will build the compiler twice. You need to set DUNE_CACHE=enabled to turn that on.

I'm using it now to generate this blog, and that's working nicely. I also tried it with Eio, but hit a problem trying to generate the docs:

  • Internal error with dune build --pkg=enable @doc-new #15290.