Use WT_REF_TRYLOCK in __wt_btcur_skip_page to avoid spinning under lock contention

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0
    • Affects Version/s: None
    • Component/s: Btree
    • None
    • Storage Engines, Storage Engines - Transactions
    • 0.001
    • None
    • None

      Problem

      In __wt_btcur_skip_page, WiredTiger acquires a ref lock via WT_REF_LOCK to safely read aggregate timestamp information before deciding whether to skip an entire page. WT_REF_LOCK spins until it obtains the lock, which is wasteful because skip_page is a pure read-path optimization — if the lock is contended, the correct behavior is simply to not skip the page and let the cursor proceed normally.

      Fix

      Add a new WT_REF_TRYLOCK macro backed by _ref_try_lock(), a non-spinning CAS that returns EBUSY immediately if the ref is already locked. Use WT_REF_TRYLOCK in _wt_btcur_skip_page and return 0 (do not skip) when the lock is unavailable.

      Validation

      Submitted a sys-perf --alias perf-required patch (31 HVW tasks) against the MongoDB tree with this change vendored in. SPS Performance Comparison showed 0 regressions across 201 data points, with 2 minor throughput improvements (Z-score ≈ 2.0–2.1 on mixed_workloads_locust). No performance regression introduced.

      Related support ticket: HELP-94648

            Assignee:
            Shoufu Du
            Reporter:
            Shoufu Du
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: