-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Statistics
-
None
-
Storage Engines - Foundations
-
225.209
-
None
-
None
Issue Summary
The discussion identified that WiredTiger read-lock acquisition counters maintained inside __wt_readlock do not count all acquisitions. There is an early fast-path return in src/support/mtx_rw.c before the per-lock statistics increment site, so acquisitions that succeed without write contention skip counters such as lock_dhandle_read_count, lock_table_read_count, and the proposed lock_truncate_list_read_count.
The generic rwlock_read counter is incremented separately at the top of the function, so it is unaffected. The gap only applies to lock-specific counters maintained by the lock implementation.
Context
- mtx_rw.c fast-path return
- mtx_rw.c stat increment site
- The original change that moved the increment later was justified by: "Read-locks can be granted without any statistics work, and it's a fair amount of work."
- This behavior is (probably) intentional for performance reasons, so the fast path stays as lightweight as possible.
- However, this makes it unclear from the stat names/descriptions that these counters are not inclusive of all lock acquisitions.
Proposed Solution
Document the behavior clearly so users understand that lock-specific read acquisition counters may exclude fast-path acquisitions. This could include:
- Updating the stat descriptions for lock-specific read counters to clarify they do not count every acquisition
- Adding documentation explaining the fast-path/stat tradeoff in __wt_readlock
- Optionally introducing a separate stat that is incremented on every lock acquisition, if a fully inclusive count is desired
Original Slack thread: Slack Thread
This ticket was generated by AI from a Slack thread.