Description
The current implementation of App.Metrics is very inefficient.
For example, I recently ran a memory profile on 300k GET operations. In this profile, there were approximately 28.6MB of strings allocated. Of those, 25.3MB (88.6%) were allocated by DefaultMetricContextRegistry.Timer<T> calling String.Concat on every GET operation (as part of OperationBase.StopRecording). There's also a further 19.3MB of related App.Metrics.Internal.DefaultMetricContextRegistry+<>c__DisplayClass33_0<ITimerMetric> allocations I can see.
A quick glance seems to indicate that we could prevent this by simply persisting an ITimer instance for reuse, or some similar approach. However, another option may be to drop App.Metrics entirely and use the .NET metric system. This is partially completed by https://review.couchbase.org/c/couchbase-net-client/+/165973, but this change still uses App.Metrics to support the LoggingMeter. Another means of building the histogram data would be required.
Attachments
For Gerrit Dashboard: NCBC-3058 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
205915,5 | NCBC-3058: Rewrite logging meter without App.Metrics | master | couchbase-net-client | Status: MERGED | +2 | +1 |