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

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 1.12.0, 1.12.0-alpha1
    • Affects Version/s: None
    • Component/s: BSON, Logging
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
              Reporter:
              Matt Dale
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: