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

Expose ITypeSerializer on IBucket to help improve Linq2Couchbase performance



    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.6.0
    • library
    • 1


      In order to support query generation, Linq2Couchbase uses the configured ITypeSerializer. The only route to get to any configuration is via IBucket. Currently, Linq2Couchbase is getting the serializer from ClientConfiguration.Serializer via IBucket.Cluster.Configuration.

      However, ClientConfiguration.Serializer isn't actually the serializer, but a factory function that creates a serializer. This means that for each query, Linq2Couchbase is instantiating a new serializer instance, causing unnecessary heap allocations. This could be somewhat optimized by caching in BucketContext, but since BucketContext is intended to be short-lived (i.e. per MVC request) the value would be minimal.

      If instead we expose the actual instance of ITypeSerializer from IBucket (which is generally a singleton), Linq2Couchbase will be able to avoid the unnecessary instantiation of additional ITypeSerializers. Additionally, it will make caching the results of some method calls on the type serializer effective (see https://github.com/brantburnett/Linq2Couchbase/blob/master/Src/Couchbase.Linq/Serialization/DefaultDateTimeSerializationFormatProvider.cs#L33), further improving query generation performance.


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


          btburnett3 Brant Burnett created issue -
          btburnett3 Brant Burnett made changes -
          Field Original Value New Value
          Status New [ 10003 ] Open [ 1 ]
          btburnett3 Brant Burnett made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          jmorris Jeff Morris made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Resolved [ 5 ]
          brett19 Brett Lawson made changes -
          Story Points 1


            btburnett3 Brant Burnett
            btburnett3 Brant Burnett
            0 Vote for this issue
            1 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes