Skip to content

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

@anuragsoni

Description

@anuragsoni

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions