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

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty