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

Lazily cache ObjectId hex string

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • bson-6.11.0
    • Affects Version/s: None
    • Component/s: None
    • 2
    • 2
    • Not Needed
    • 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?

      Use Case

      When ObjectId.cacheHexString is enabled there is a performance impact on ObjectId creation and the extra memory used by the hex string is consumed even if .toHexString is never called on the ObjectId.

      By lazily caching the hex string it provides the following benefits:

      • No performance impact on ObjectId creation
      • Memory use does not increase unless string is requested
      • Duplicate .toHexString calls are still efficient as cache is used

      Possible Negatives:

      • hex string performance impact is moved to first .toHexString() invocation. Overall performance is still consistent, but it is not front loaded on ObjectId creation.

       

      I will submit a PR to address this issue.

       

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            sean.reece@precisely.com Sean Reece
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: