Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experiment] Cstruct to Bstruct #101

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

patricoferris
Copy link
Contributor

@patricoferris patricoferris commented Aug 21, 2023

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 ocaml-multicore/eio#140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant