Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5740

Remove unnecessary buffer concatenation in wire protocol serialization

      Use Case

      As a driver engineer,
      I want to remove unnecessary buffer concatenation in our wire protocol abstraction,
      So that we remove unnecessary buffer allocations.

       

      Wire protocol messages in the Node driver implement a `toBin()` method that returns a serialized wire protocol message.  `toBin()` returns an array of Uint8Arrays.  The message stream ( and the forthcoming new connection layer ) call `toBin()` and then concatenate the buffers before writing this to the socket.

      The socket write api accepts a buffer - there's no reason we can't just write each buffer returned by `toBin()` to the socket directly.  We should remove the unnecessary `Buffer.concat` calls and write each chunk to the socket directly.

      User Impact

      • n/a

      Dependencies

      • n/a

      Unknowns

      Acceptance Criteria

      Implementation Requirements

      • In the message stream, when a wire protocol message is serialized, change the logic to write each buffer sequentially instead of concatenating them into a buffer and writing the concatenated buffer

      Testing Requirements

      • ensure existing tests pass

      Documentation Requirements

      • none

      Follow Up Requirements

      • none

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: