Improve BSON serialization performance

XMLWordPrintableJSON

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

      During extensive benchmarking of BSON serialization/deserialization performance to test  NODE-6246 I found that most document properties cause multiple calls to `Object.prototype.toString.call(prop)` which are quite expensive. By refactoring the serialization checks to move these calls out of hot paths could result in ~20% serialization performance (testing with MFlix dataset). By also integrating a WeakMap cache to essentially memoize calls to `Object.prototype.toString.call(prop)` can increase performance of serialization and calculateSize to 20-40%.

      https://github.com/mongodb/js-bson/pull/709

              Assignee:
              Durran Jordan
              Reporter:
              Sean Reece
              Durran Jordan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: