[GODRIVER-2734] Reduce memory allocations in "bson.Raw.String" to improve logging performance Created: 18/Jan/23  Updated: 28/Oct/23  Resolved: 20/Jan/23

Status: Closed
Project: Go Driver
Component/s: BSON, Logging
Affects Version/s: None
Fix Version/s: 1.12.0, 1.12.0-alpha1

Type: Improvement Priority: Major - P3
Reporter: Matt Dale Assignee: Matt Dale
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to GODRIVER-1712 Easier debugging with standardized lo... Closed

 Description   

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.


 Comments   
Comment by Githook User [ 20/Jan/23 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-2734 Benchmark and reduce allocations in bson.Raw.String (#1160)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/de9108a5c0d9f3bfc51c6f654ecb406d274885c0

Comment by Matt Dale [ 18/Jan/23 ]

PR: https://github.com/mongodb/mongo-go-driver/pull/1160

Generated at Thu Feb 08 08:39:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.