Optimize __wti_page_inmem_updates to bypass binary search in row-leaf path

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Minor - P4
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Btree
    • None
    • Storage Engines - Transactions
    • 779.264
    • SE Transactions - 2026-05-22
    • 3

      Overview

      In _wti_page_inmem_updates, the row-leaf branch previously called _wt_row_search on every row to determine where to apply the update. Since WT_ROW_FOREACH already provides the exact row pointer, the binary search was redundant and wasteful.

      Changes

      Position the cursor directly instead of searching:

      • Set cbt.compare = 0 and cbt.ref = ref once before the loop.
      • Set cbt.slot = WT_ROW_SLOT(page, rip) per iteration.
      • Call __wt_row_modify directly with a NULL key.

      When compare=0 and ins=NULL, __wt_row_modify writes directly to mod_row_update[slot] and never reaches the insert path where the key parameter is required. This also eliminates the key scratch buffer allocation (WT_DECL_ITEM(key)) entirely.

      Impact

      • Removes one binary search and one scratch buffer allocation per prepared or stop-timestamped row on every row-leaf page instantiation.
      • The hot path for __wti_page_inmem_updates on large row-leaf pages is measurably cheaper.

      Related Files

      • src/btree/bt_page.c__wti_page_inmem_updates
      • src/btree/row_modify.c__wt_row_modify (no changes, logic verified)

            Assignee:
            Haribabu Kommi
            Reporter:
            Haribabu Kommi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: