-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: 3.0.0
-
Component/s: Performance, Read Operations
-
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 |