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

Performance: Reduce byte buffer allocations while writing to server

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.12.0
    • Affects Version/s: 2.8.1, 2.9.0
    • Component/s: Performance, Serialization
    • Labels:
      None

      Similar to https://jira.mongodb.org/browse/CSHARP-2692, calling Utf8Encoding.GetBytes without specifying a byte buffer should be avoided at all costs for best performance.

      The current implementation of ByteBufferStream does already have a concept (using the "_tempUtf8" buffer) where it ends up calling the fast GetBytes() overload that doesn't allocate its own buffer for strings up to a length that fits into a byte[128] buffer. The 128 elements are a hard limit, though, so for bigger strings, there is a performance penalty.

      I suggest changing this by auto-growing the byte[128] buffer to handle bigger strings, too. This is trading a little bit of memory for performance.

            Assignee:
            boris.dogadov@mongodb.com Boris Dogadov
            Reporter:
            daniel.hegener@gmx.net Daniel Hegener
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: