-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
Statistics are not designed to be 100% accurate all the time as implementing locks on reads would often be too expensive given the use case.
A user has recently reported that the cache_bytes_max statistic occasionally returns an incorrect zero value. This is plausible as it is possible two cursors may race when collecting this metric. Looking into the code further, we see that the stat value is being reset before being assigned with the new value:
#define WT_STAT_SET(session, stats, fld, value) \ do { \ if (WT_STAT_ENABLED(session)) { \ __wt_stats_clear(stats, WT_STATS_FIELD_TO_OFFSET(stats, fld)); \ (stats)[0]->fld = (int64_t)(value); \ } \ } while (0)
We would like to investigate whether it is plausible to guarantee correct values without negatively impacting performance. A potential approach could be to avoid resetting cache configurations each time by utilizing atomics to swap in newer statistic values. If this solution exhibits more efficient performance, we could extend this to other statistics as well.