Ask questionsReplace flatbuffers

Our benchmarks are finally at the point where we're able to measure the overhead of serialization. The gap below is due to serialization: Screen Shot 2019-04-15 at 1 13 19 PM Flatbuffers appears to now be our bottleneck (see benchmarks in

Here are our requirements for a new serialization library:

  1. Supports Rust and TypeScript.
  2. Generated Rust code complicates our build system. Ideally we could specify the message schema using Rust structs to avoid this.
  3. Must be able to serialize into existing byte slice (&[u8] in Rust or Uint8Array in JS). That is, it should not return a newly allocated slice.
  4. Must support (at minimum) String and i32 types within a struct.
  5. At minimum be able to handle 200k serialization/deserialization per second. But probably needs to be more like 2m/sec in order to close the above throughput gap

Answer questions ry

Some of our messages are very small - two int32 integers. We need a framework which can take a struct like

struct ReadMessage {
  rid: i32;

and compile into JavaScript code which only does the bare minimum:

interface ReadMessage { rid: number };

function ReadMessageParse(i32: Int32Array) => ReadMessage {
  assert(i32[0] == READ_MESSAGE_ID);
  return { rid: i32[1] };

function ReadMessageSerialize(msg: ReadMessage, i32: Int32Array): void {
  i32[0] = READ_MESSAGE_ID;
  i32[1] = msg.rid;

We know this is fast... Unfortunately existing systems seem to have a lot more code. I'd be interested to know if cap'n'proto can produce minimal code like this.