Treat busy-blocked page-in as stall for earlier eviction assist

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Cache and Eviction
    • None
    • Storage Engines
    • None
    • None

      Problem

      Off-CPU profiling of ycsb.out_of_cache.100read at 128 threads shows 48.5% of total off-CPU time in sched_yield, originating from WiredTiger spinlock contention paths. Within __wt_page_in_func (bt_read.c), when __wt_hazard_set_func fails because a page is busy being evicted (busy = true), the code increments page_busy_blocked and breaks to the retry loop, but critically does not set stalled = true. This means the thread enters a tight __wt_yield() loop for up to 1000 iterations before progressing to adaptive backoff. With 128 threads and constant eviction pressure, pages remain busy far longer than 1000 yields, so threads waste CPU spinning instead of helping resolve the eviction bottleneck.

      The WT_REF_LOCKED case already sets stalled = true for exactly this reason, but the busy case was overlooked.

      Solution

      Set stalled = true inside the if (busy) block in {}wt_page_in_func (bt_read.c, line 613), matching the existing behavior of the WT_REF_LOCKED case. This causes threads blocked on a busy page to bypass the 1000-iteration yield loop and proceed directly to the adaptive backoff path, where they first attempt to assist with eviction via _wt_evict_app_assist_worker_check, turning wasted yield cycles into productive work that clears the exact bottleneck the thread is waiting on. If no eviction work is available, the thread sleeps with adaptive backoff (_wt_spin_backoff, starting at 100us), freeing CPU for other threads.

      This is a one-line change. The stalled flag only affects retry strategy (yield vs sleep/eviction-assist), not page access logic.

            Assignee:
            Jawwad Asghar
            Reporter:
            Jawwad Asghar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: