From a403e5531935eebdd950c2cb0bc45206830f2032 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Thu, 10 Jul 2025 15:52:18 +0300 Subject: [PATCH] btree: add comment about when left-to-right size balancing is stopped --- core/storage/btree.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/storage/btree.rs b/core/storage/btree.rs index c27ae04e9..fd74ea62e 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -2867,6 +2867,9 @@ impl BTreeCursor { } else { CELL_PTR_SIZE_BYTES as i64 }; + // As mentioned, this step rebalances the siblings so that cells are moved from left to right, since the previous step just + // packed as much as possible to the left. However, if the right-hand-side page would become larger than the left-hand-side page, + // we stop. let would_not_improve_balance = size_right_page + cell_right_size + (CELL_PTR_SIZE_BYTES as i64) > size_left_page - (cell_left_size + pointer_size);