Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-5412

Performance: Avoid allocations of BsonDeserializationContext when deserialising a batch

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.1.0
    • Affects Version/s: 3.0.0
    • None
    • Fully Compatible
    • Dotnet Drivers
    • Not Needed

      When deserialising a result batch, a BsonDeserializationContext is created for each document/object.

      The logic can be changed to reuse the BsonDeserializationContext instance for each document/object.

      The same reuse already happens in the driver in  CommandMessageBinaryEncoder.ReadType1Section.

      This reduces allocations and GC load.

      Current implementation:

      Method BenchmarkDataSetSize Mean Error StdDev Gen0 Gen1 Gen2 Allocated
      MultiFileExport 565000000 8.230 s 0.7249 s 0.1882 s 516000.0000 304000.0000 3000.0000 7.73 GB

      Reuse implementation:

      Method BenchmarkDataSetSize Mean Error StdDev Gen0 Gen1 Gen2 Allocated
      MultiFileExport 565000000 8.191 s 0.2030 s 0.0314 s 514000.0000 318000.0000 3000.0000 7.68 GB

       

            Assignee:
            ferdinando.papale@mongodb.com Ferdinando Papale
            Reporter:
            obligaron@live.com obligaron N/A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: