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

Reduce array allocations in BsonStreamAdapter

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.7.3
    • Component/s: Performance, Serialization
    • Labels:
      None

      BsonStreamAdapter already uses some kind of an array reuse concept using the _tempUtf8 variable. This approach could, however, be significantly improved by dropping this helper variable and instead switching to System.Buffers.ArrayPool<byte>. The reason being that e.g. for the UTF8 conversions in WriteString() and WriteCString, the buffers are only needed for a very short time and can immediately (at the end of the very same method) be returned back to the pool once the buffer has been written into the output stream.

            Assignee:
            Unassigned Unassigned
            Reporter:
            daniel.hegener@gmx.net Daniel Hegener
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: