Improve disagg leaf delta hot path by eliminating struct_pack overhead

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Page deltas
    • None
    • Storage Engines, Storage Engines - Transactions
    • 0.001
    • SE Transactions - 2026-06-19
    • 3

      Background

      __wti_rec_pack_delta_row_leaf is called once per changed key during disaggregated leaf delta reconciliation. It encodes a flags byte and the cell value into a custom buffer using the format WT_DELTA_LEAF_VALUE_FORMAT = "Bu".

      Problem

      The encoding used _wt_struct_size followed by _wt_struct_pack — two general-purpose packing calls that each set up a va_list, iterate the format string, and call __pack_next per field. This overhead was paid on every key in the delta, making it a hot-path cost in write-heavy workloads.

      Fix

      "Bu" encodes exactly one raw byte followed by raw item data with no length prefix, so the encoded size is always 1 + value.size. Replace the two struct pack calls with a direct byte store of the flags and a memcpy of the value data.

      custom_value_size = 1 + value.size;
      WT_ERR(__wt_scr_alloc(session, custom_value_size, &custom_value));
      ((uint8_t *)custom_value->mem)[0] = flags;
      if (value.size > 0)
          memcpy((uint8_t *)custom_value->mem + 1, value.data, value.size);
      custom_value->size = custom_value_size;
      

      This eliminates 2 function calls, 2 va_list setups, and 4 __pack_next iterations per key. The encoding produced is identical to what __wt_struct_pack would produce for this fixed format.

            Assignee:
            Ravi Giri
            Reporter:
            Ravi Giri
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: