[PATCH v2 1/2] maple_tree: simplify split calculation

Liam R. Howlett Liam.Howlett at oracle.com
Tue Nov 12 17:44:36 PST 2024


* Wei Yang <richard.weiyang at gmail.com> [241112 20:15]:
> On Tue, Nov 12, 2024 at 09:46:20AM -0500, Liam R. Howlett wrote:
> >* Wei Yang <richard.weiyang at gmail.com> [241109 08:45]:
> >> We have been too smart to calculate split value.
> >> 
> >> The purpose of current calculation is to avoid having a range less than
> >> the slot count. But this seems to push too hard to suffer from jitter
> >> problem.
> >> 
> >> Considering this only matters if the range is less than the slot count,
> >> so the real world implications of the calculation will be negligible. So
> >> we decide to simplify the calculation of split.
> >> 
> >> Also current code may lead to deficient node, the condition to check
> >> should be (b_end - split - 1 > slot_min). After this change, this one is
> >> gone together.
> >
> >This comment is difficult to understand.
> >
> >Maybe something like:
> >The current calculation for splitting nodes tries to enforce a minimum
> >span on the leaf nodes.  This code is complex and never worked correctly
> >to begin with, due to the min value being passed as 0 for all leaves.
> >
> >The calculation should just split the data as equally as possible
> >between the new nodes.  Note that b_end will be one more than the data,
> >so the left side is still favoured in the calculation.
> >
> >The current code may also lead to a deficient node by not leaving enough
> >data for the right side of the split. This issue is also addressed with
> >the split calculation change.
> >
> 
> Thanks, this looks much better :-)
> 
> >> 
> >> Signed-off-by: Wei Yang <richard.weiyang at gmail.com>
> >
> >Fixes: ?
> >Cc: stable ?
> >
> 
> Will add this.
> 
> BTW, as this is a fix, do you think the test case in patch 2 of v1 is still
> necessary?

Yes, please include it.

I keep all test cases from fixed bugs or added features.  This way we
know that the bug doesn't return in another unrelated change.  The
testcases continuously grow, but they are always useful.

Thanks,
Liam



More information about the maple-tree mailing list