OAK-5956 improved the statistics collected for the segment cache. As I expected this had an impact on performance as measured by our micro benchmarks. An impact is visible for ConcurrentReadTest, ConcurrentReadWriteTest and ConcurrentWriteTest. Impact on full stack operation is yet to be determined (I assume it is neglectable though).
The impact seems to be mostly caused by the SegmentId.onAccess callback.
- Replace the SegmentId.onAccess callback with a direct reference to the underlying counter.
- Allow disabling of the cache statistics.
- Do nothing and accept the performance impact.
The first approach is least attractive as it breaks encapsulation. Depending on the impact of this on full stack operations I'd either go with the 2nd or 3rd option.