Avoid byte array allocations writing Int64, Double, Decimal128 in ByteBufferStream

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Unknown
    • 3.7.0
    • Affects Version/s: 3.4.0, 3.5.0, 3.6.0
    • Component/s: None
    • None
    • Fully Compatible
    • Dotnet Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      We encountered significant memory allocations and GC pressure when writing multiple classes containing integer/double with the C# driver. I have tested version 3.4-3.6, and each have this issue.

      These allocations occur as byte array allocations, from ByteBufferStream.WriteDouble and ByteBufferStream.WriteInt64
      The below is from Visual Studio 2026 Object Allocation Profiling, running .NET 10

      I noticed there exists a _temp array that exists in ByteBufferStream, that is used in other areas of reading/writing (Eg: WriteInt32), and had the thought if it possible to reuse in those areas aswell, as the data is under 12 bytes.

      I assume this is conceptually similar to issue 5531 / GitHub PR 1670

            Assignee:
            Boris Dogadov
            Reporter:
            Lily N/A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: