In hs_rec.c, we increment the statĀ cache_hs_insert insideĀ the hs_insert_record function by doing the following:
WT_STAT_CONN_DATA_INCR(session, cache_hs_insert);
Instead, we should consider updating the stat outside this function, i.e in wt_hs_insert_updates, and use the following:
WT_STAT_CONN_DATA_INCRV(session, cache_hs_insert, insert_cnt);
This would reduce the number of calls related to this stat.
Suggested solution:
diff --git a/src/history/hs_rec.c b/src/history/hs_rec.c
index 0e7e6dd2e..5df5f75f9 100644
--- a/src/history/hs_rec.c
+++ b/src/history/hs_rec.c
@@ -241,7 +241,6 @@ __hs_insert_record(WT_SESSION_IMPL *session, WT_CURSOR *cursor, WT_BTREE *btree,
cursor->set_value(
cursor, tw, tw->durable_stop_ts, tw->durable_start_ts, (uint64_t)type, hs_value);
WT_ERR(cursor->insert(cursor));
- WT_STAT_CONN_DATA_INCR(session, cache_hs_insert);
err:
if (!hs_read_all_flag)
@@ -774,6 +773,8 @@ err:
WT_TRET(hs_cursor->close(hs_cursor));
+ /* Update history store related stats. */
+ WT_STAT_CONN_DATA_INCRV(session, cache_hs_insert, insert_cnt);
WT_STAT_CONN_DATA_INCRV(session, cache_hs_insert_full_update, cache_hs_insert_full_update);
WT_STAT_CONN_DATA_INCRV(
session, cache_hs_insert_reverse_modify, cache_hs_insert_reverse_modify);