Open
Description
Performing IO operations with the kernel requires giving the kernel the address of a buffer that the GC won't move during the operation. To ensure that, we use Cstruct.t
everywhere. However, there are rumours (mirage/ocaml-cohttp#819 (comment)) that regular strings in OCaml 5 are sure to stay put, at least once they're in the major heap.
- Using regular strings/bytes is likely to be slightly faster than a cstruct (which wraps a bigarray).
- It would integrate better with other OCaml APIs.
- We would have to ensure that a buffer is on the major heap (and move it if not) when doing IO. This would involve extra copying if not careful.
- There are severe length restrictions on strings on 32-bit platforms, as the top bits of the length field are used for other things.
- Only cstructs work with memory-mapped data.
Tasks:
- Confirm that OCaml 5 guarantees that strings will not be moved.
- Measure performance difference of strings vs cstructs.
/cc @avsm @kayceesrk