Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2765

Improve buffer handling in MultiplexingConnection receive

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.1.0
    • 3.1.1
    • library
    • None
    • 1

    Description

      The current receive buffer scales too aggressively, retains more memory than necessary in some cases, and is inefficient when additional operations are received in the same read from the socket.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          Throughput test app I used:

          using System;
          using System.Diagnostics;
          using System.Linq;
          using System.Threading.Tasks;
          using Couchbase.Core.IO.Transcoders;
          using Couchbase.Extensions.DependencyInjection;
          using Couchbase.KeyValue;
          using Microsoft.Extensions.DependencyInjection;
           
          var serviceProvider = new ServiceCollection()
              .AddLogging()
              .AddCouchbase(options =>
              {
                  options.ConnectionString = "couchbase://localhost";
                  options.UserName = "Administrator";
                  options.Password = "password";
              })
              .BuildServiceProvider();
           
          var bucket = await serviceProvider.GetRequiredService<IBucketProvider>().GetBucketAsync("default");
          var collection = bucket.DefaultCollection();
           
          var transcoder = new RawBinaryTranscoder();
           
          var data = new byte[256 * 1024];
          await collection.UpsertAsync("test", data, new UpsertOptions().Transcoder(transcoder));
           
          var getOptions = new GetOptions().Transcoder(transcoder);
           
          var tasks = Enumerable.Range(1, 20)
              .Select(i => Task.Run(async () =>
              {
                  for (var j = 1; j <= 1000; j++)
                  {
                      await collection.GetAsync("test", getOptions);
                  }
              }));
           
          var stopwatch = new Stopwatch();
          stopwatch.Start();
           
          await Task.WhenAll(tasks);
           
          stopwatch.Stop();
           
          Console.WriteLine($"Elapsed: {stopwatch.ElapsedMilliseconds:#0}ms");
          

          btburnett3 Brant Burnett added a comment - Throughput test app I used: using System; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Couchbase.Core.IO.Transcoders; using Couchbase.Extensions.DependencyInjection; using Couchbase.KeyValue; using Microsoft.Extensions.DependencyInjection;   var serviceProvider = new ServiceCollection() .AddLogging() .AddCouchbase(options => { options.ConnectionString = "couchbase://localhost" ; options.UserName = "Administrator" ; options.Password = "password" ; }) .BuildServiceProvider();   var bucket = await serviceProvider.GetRequiredService<IBucketProvider>().GetBucketAsync( "default" ); var collection = bucket.DefaultCollection();   var transcoder = new RawBinaryTranscoder();   var data = new byte [256 * 1024]; await collection.UpsertAsync( "test" , data, new UpsertOptions().Transcoder(transcoder));   var getOptions = new GetOptions().Transcoder(transcoder);   var tasks = Enumerable.Range(1, 20) .Select(i => Task.Run( async () => { for ( var j = 1; j <= 1000; j++) { await collection.GetAsync( "test" , getOptions); } }));   var stopwatch = new Stopwatch(); stopwatch.Start();   await Task.WhenAll(tasks);   stopwatch.Stop();   Console.WriteLine($ "Elapsed: {stopwatch.ElapsedMilliseconds:#0}ms" );

          People

            btburnett3 Brant Burnett
            btburnett3 Brant Burnett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty