Skip to content

Navigation Menu

Sign in
Sign up

significantly reduce copies #31

Open

Description

There are several places in the code where copies are made just for ease of implementation. Eventually we will want to minimize these. Can we make a more sharing-friendly structure that minimizes copies, and supports Buf semantics? Rc<Box<Vec>> backed?

A write request involves at least these copies:

  1. sk_buff
  2. 1024 byte MutByteBuf
  3. Codec buffer
  4. deframed buffer
  5. parse into SetReq protobuf
  6. create Mutation protobuf
  7. for each peer, each Mutation is cloned and that value is placed into a new batch protobuf (is that one copy or two?)
  8. for each peer, the batch protobuf is converted to bytes
  9. for each peer, the bytes are framed using the Codec
  10. for each peer, the bytes are added to the outbound Vec
  11. for each peer, incrementally send bytes into sk_buff's for sockets to them
  12. for each peer, essentially repeat this process to parse and formulate a simple response
  13. for the leader, essentially repeat steps 1-5

So, for a cluster of 5, the write amplification is in the high dozens before we even talk about RocksDB. We are at least two orders of magnitude from being optimal.

Questions:

  1. can we implement a Codec that receives bytes directly from an sk_buff to skip basic mio loop and leader election #2 above?
  2. can we have a format that uses field offsets in a header to unsafely dereference interesting parts of requests?
  3. can we wrap this in a structure that is copyable without copying the underlying buffer? This would allow the structure to be copied all over the place without actually copying the data, just the read offsets for Buf. inner: Rc<Box<?>>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      AltStyle によって変換されたページ (->オリジナル) /