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

BSON marshal/unmarshal perf has degraded significantly vs mgo

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 0.0.8
    • Fix Version/s: None
    • Component/s: BSON
    • Labels:
    • Environment:
      macOS 10.13.2
      centos 7.5.1804

      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!

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              duncan.armstrong Duncan Armstrong
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: