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

Consider using a record based Buffer.t to represent iovecs for cheaper sub operation #124

Open
anuragsoni opened this issue Jul 30, 2021 · 2 comments

Comments

@anuragsoni
Copy link

It might be nice to represent Buffer.t using a record as opposed to a straight up bigstring. ex:

type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
type t = { buf: bigstring; pos: int; len: int}

In some simple benchmarks in the past i've noticed the sub operation to be a little faster for the record based representation, than using the sub operation from Bigarray.Array1.

┌─────────────────┬──────────┬─────────┬────────────┐
│ Name            │ Time/Run │ mWd/Run │ Percentage │
├─────────────────┼──────────┼─────────┼────────────┤
│ Iovec           │   2.55ns │   4.00w │     10.96% │
│ Bigstringaf.sub │  23.25ns │   7.00w │    100.00% │
└─────────────────┴──────────┴─────────┴────────────┘

Potentially relevent discussion: https://discuss.ocaml.org/t/hannes-mehnert-interview-about-mirageos-and-ocaml-by-evrone/5784/10

@talex5
Copy link

talex5 commented Aug 20, 2021

Any chance of using Cstruct.t for this? Would save copying between all the various versions of this type. Eio is already wrapping luv buffers in cstructs.

@aantron
Copy link
Owner

aantron commented Aug 20, 2021

There is a chance, but I haven't had time to evaluate the various options yet.

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

No branches or pull requests

3 participants