| ... | ... | @@ -1544,25 +1544,6 @@ fn growNodeViaInsertRange( |
| 1544 | 1544 | // We don't compute the size of the range yet, because depending on `grow_mode` we might want to |
| 1545 | 1545 | // bump it based on our sibling and parent nodes' alignments. However, we can do an early check |
| 1546 | 1546 | // for cases where we should obviously exit. |
| 1547 | | const requested_range_size = new_size - old_size; |
| 1548 | | if (!mf.flags.block_size.check(requested_range_size)) { |
| 1549 | | // The requested size isn't exactly aligned. |
| 1550 | | switch (grow_mode) { |
| 1551 | | .exact => return false, |
| 1552 | | .minimum => { |
| 1553 | | // We can still choose to allow it by increasing the size a bit, but we shouldn't do |
| 1554 | | // that if it would *significantly* increase the requested size. |
| 1555 | | const block_size = mf.flags.block_size.toByteUnits(); |
| 1556 | | if (requested_range_size < block_size * 2) { |
| 1557 | | // Bumping this size up to the next block boundary would be a quite significant |
| 1558 | | // increase; let's not do it. |
| 1559 | | return false; |
| 1560 | | } |
| 1561 | | }, |
| 1562 | | } |
| 1563 | | } |
| 1564 | | // If `grow_mode` is exact, we will use exactly this size, but if it is `.minimum`, we may bump |
| 1565 | | // the size a little more. |
| 1566 | 1547 | const min_range_size: u64 = s: { |
| 1567 | 1548 | const exact_size = new_size - old_size; |
| 1568 | 1549 | if (mf.flags.block_size.check(exact_size)) { |
| ... | ... | @@ -1649,16 +1630,16 @@ fn growNodeViaInsertRange( |
| 1649 | 1630 | } |
| 1650 | 1631 | // Traversal done. We didn't hit `max_moved_nodes`, so now we can use the computed alignment |
| 1651 | 1632 | // requirement to figure out whether we're actually going to insert a range. |
| 1652 | | if (need_range_align.check(requested_range_size)) { |
| 1653 | | break :range_size requested_range_size; |
| 1633 | if (need_range_align.check(min_range_size)) { |
| 1634 | break :range_size min_range_size; |
| 1654 | 1635 | } |
| 1655 | | // Perhaps we're allowed to grow by more than `requested_range_size`? |
| 1636 | // Perhaps we're allowed to grow by more than `min_range_size`? |
| 1656 | 1637 | switch (grow_mode) { |
| 1657 | 1638 | .exact => return false, |
| 1658 | 1639 | .minimum => { |
| 1659 | 1640 | const candidate_range_size = need_range_align.forward(min_range_size); |
| 1660 | 1641 | // Allow growing by up to 50% more than was requested. |
| 1661 | | if (candidate_range_size <= requested_range_size +| requested_range_size / 2) { |
| 1642 | if (candidate_range_size <= min_range_size +| min_range_size / 2) { |
| 1662 | 1643 | break :range_size candidate_range_size; |
| 1663 | 1644 | } else { |
| 1664 | 1645 | return false; |