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

Refactor BSON ByteUtils to eliminate redundant toLocalBufferTypeCalls

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: BSON, Performance
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      In making the changes in NODE-5363, it was identified that since ByteUtils.toLocalBufferType is called directly on user input at both deserializeStream and deserialize, then all of the subsequent calls to ByteUtils.toLocalBufferType which occur inside other ByteUtils helper functions called inside src/parser/deserializer.ts are redundant and should be removed as they have a non-negligible performance impact.

      Use Case

      As a... driver engineer
      I want... to eliminate redundant toLocalBufferType calls
      So that... bson string deserialization performance will increase

      User Impact

      • This change will provide a performance increase in string deserialization

      Dependencies

      • N/A

      Unknowns

      • We currently use toLocalBufferType to ensure type safety. How can we maintain type safety in both our web and node implementations of ByteUtils?

      Acceptance Criteria

      Implementation Requirements

      • If possible, ensure that toLocalBufferType is called once and only once for each call to deserialize or deserializeStream, otherwise, eliminate as many calls to toLocalBufferType as possible while preserving type safety

      Testing Requirements

      • Add unit tests to ensure that toLocalBufferType is called as few times as possible as determined by the answers to the unknowns.
      • Manually test performance of string deserialization code paths and check that this does in fact give a performance increase in line with or greater than what was found in the investigation of NODE-4283.

      Documentation Requirements

      • N/A

      Follow Up Requirements

      • additional tickets to file, required releases, etc

            Assignee:
            Unassigned Unassigned
            Reporter:
            warren.james@mongodb.com Warren James
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: