ocaml-uring
ocaml-uring copied to clipboard
[Experiment] Cstruct to Bstruct
This is an experiment to switch away from Cstruct to Bstruct (bytes-backed Cstruct). The main issue is that the bytes are in the OCaml heap but we have to ensure they don't move. I started playing around with an allocator (Uring.Slab) which allocates a big bytes area upfront and the carves it up as the user requests slices (returned as Bstruct.t). For this to work properly the Uring.Slab implementation needs a few more tricky features:
- The bytes array probably needs to be more dynamic so it can create other big bytes areas when there's a lot of requests for slices.
- Slices that are finished with, should be garbage-collected which probably means having some reference counting.
Opening this PR in case other people want to have a play around. Note this will only work with OCaml 5+ and is related to https://github.com/ocaml-multicore/eio/issues/140