[GODRIVER-487] BSON marshal/unmarshal perf has degraded significantly vs mgo Created: 09/Jul/18  Updated: 14/May/21  Resolved: 30/Jul/18

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 0.0.8
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Duncan Armstrong Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: FreeMonitoring
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

macOS 10.13.2
centos 7.5.1804


Issue Links:
Depends
depends on GODRIVER-494 BSON Codec Redesign Closed
Related
related to GODRIVER-1946 Explore github.com/goccy/go-reflect p... Closed

 Description   

In Cloud Free Monitoring we're seeing very slow performance is bson.Marshal()/Unmarshal() (and mongo.Cursor.Decode()).

Where our query might take 10s of millis on the DB, returning ~4000 largish documents, unmarshaling them into our model structs takes 4-5 seconds - approximately 1ms per doc! These docs are on the order of 10kb in size.

We also have an area where we read larger documents (~40kb each), and these are even slower to unmarshal - on the order of 3ms/doc.

Dropping mgo into the same codebase (just for BSON marshal/unmarshal - with mongo-go-driver in-place for driver duties) saw approximately 20x improvement.

Out of curiosity, I put together some benchmarks using canned structs of varying size and object depth, comparing BSON marshal/unmarshal in mgo and mongo-go-driver: https://github.com/dunkyboy/mongo-driver-bench. The benchmarks corroborated our findings, showing mgo at ~3x faster for very simple structs, and 40x+ faster for larger, more complex structs.

FWIW we're planning on working around this in Cloud Free Monitoring by using mgo purely for BSON marshal/unmarshal. But we'd much prefer to just use mongo-go-driver, so looking forward to improvements!



 Comments   
Comment by Kristofer Brandow (Inactive) [ 30/Jul/18 ]

Closing this a duplicate of GODRIVER-494.

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