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

Address performance regressions introduced in bson v5.0.0

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.0, 5.1.0, 5.2.0, 5.3.0, 5.4.0, 5.5.0, 5.6.0
    • Component/s: BSON
    • Not Needed
    • 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?

      Background

      There was a severe performance regression in string deserialization introduced in bson v5 (https://docs.google.com/spreadsheets/d/1Wogm3APTMcZJK4BjXVx5xTaIGQkrtr38GzP89Nd3FV8/edit?usp=sharing) which is related to the implementation of ByteUtils.toUTF8 which is called primarily by getValidatedString in src/parser/deserializer.ts (see flamegraph below.) This issue affects all currently released versions of the driver starting from v5.0.0 which is where the dependency on bson v5 was added.

      Unknowns

      • What would the impact of trying to reduce/eliminate calls to ByteUtils.toLocalBufferType?
      • How difficult will it be to get the Typescript to work as we'd like it to if we remove ByteUtils.toLocalBufferType calls?

      Acceptance Criteria

      • Update ByteUtils.toUTF8 in src/utils/node_byte_utils.ts to take in start and end and pass them through to the call to toString rather than calling Buffer.subarray directly inside getValidatedString.
        • Address any typescript issues this causes
      • Investigate how to reduce/eliminate calls to ByteUtils.toLocalBufferType in ByteUtils.toUTF8
      • Audit the remainder of ByteUtils to investigate if there is anywhere else that we are taking an unnecessary performance hit
      • Investigate best approach to adding regression tests specifically for the performance of getValidatedString and possibly of ByteUtils.toUTF8 and add these tests.

       

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

              Created:
              Updated:
              Resolved: