1

Is the Diagnostics class Sitecore.Diagnostics.PerformanceCounters.DataCount thread-safe (or perhaps, I mean accurate in the context of multiple threads).

I noticed that it is used by Sitecore to track the number of items accessed while rendering a rendering, but what happens if another thread access items which then changes the DataCount values independently?

1

Is Sitecore.Diagnostics.PerformanceCounters.DataCount thread-safe. Yes, it is.

Is it accurate in the context of multiple threads? No.

The DataCount class uses static instances of the AmountPerSecondCounter class. Any thread could update this instance, so it is not 100% accurate in this case. It is used for debugging purposes e.g. the Sitecore debug UI (which shows stuff like rendering time, items read and cache hits etc for each rendering on a page). I think it's safe to say that it's good enough for debugging purposes. If you had multiple people debugging at the same time on the same environment, then you could encounter inaccuracies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.