-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Go Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Detailed steps to reproduce the problem?
There is a notable difference between benchmarking encoding between v1 and master of the Go Driver.
v1:
goos: darwin goarch: arm64 pkg: go.mongodb.org/mongo-driver/bson cpu: Apple M1 Pro BenchmarkMarshal/BSON/nested_struct-10 2706303 453.9 ns/op 416 B/op 1 allocs/op PASS ok go.mongodb.org/mongo-driver/bson 1.970s
master:
goos: darwin goarch: arm64 pkg: go.mongodb.org/mongo-driver/v2/bson cpu: Apple M1 Pro BenchmarkMarshal/BSON/nested_struct-10 639736 1948 ns/op 4830 B/op 13 allocs/op PASS ok go.mongodb.org/mongo-driver/v2/bson 1.745s
Looking at commits around the time of the BSON v2 implementation, the > 1 allocation problem began with 8c5c0b0. Performance was somewhat improved with 4c6d174 to “Re-add marshal optimizations”. But the results are still pretty bad.
Notably, we don't carry over the valueWriter buffer for encoding in the implementation on master, instead we create a new document writer every time.
Definition of done: what must be done to consider the task complete?
Add a valueWriter sync.Pool back to the Marshal function in the bson package: https://github.com/mongodb/mongo-go-driver/blob/f7546adc4002ef89a78b8ad8def4aaffe000d5bd/bson/marshal.go#L193-L194
The exact Go version used, with patch level:
go version go1.23.1 darwin/arm64
The exact version of the Go driver used:
2.1.0
Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.
NA
The operating system and version (e.g. Windows 7, OSX 10.8, ...)
OSX 15.4
Security Vulnerabilities
NA
- related to
-
GODRIVER-3450 Improve pooled buffer reuse pattern
-
- Backlog
-