Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-2734

Reduce memory allocations in "bson.Raw.String" to improve logging performance

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.12.0, 1.12.0-alpha1
    • Affects Version/s: None
    • Component/s: BSON, Logging
    • None

      There are a number of simple optimizations we can make to bsoncore.Document.String, bsoncore.Array.String, and bsoncore.Element.String that can significantly reduce allocations. Historically those haven't been a major concern, but the logging implementation (GODRIVER-1712) for command logging relies heavily on the bson.Raw.String function.

      Definition of done:

      • Replace all uses of bytes.Buffer with strings.Builder in bsoncore where the function output is a string.
      • Remove all uses of fmt.Fprintf and fmt.Sprintf where there is little or no string formatting added.
      • Add a benchmark that exercises bson.Raw.String for various inputs.

            Assignee:
            matt.dale@mongodb.com Matt Dale
            Reporter:
            matt.dale@mongodb.com Matt Dale
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: