sum_tree: Implement recursive Sumtree::find, use it over Cursor::seek if possible (#40700)

Reduces peak stack usage in these functions and should generally be a
bit performant.

Display map benchmark results
```
To tab point/to_tab_point/1024
                        time:   [531.40 ns 532.10 ns 532.97 ns]
                        change: [-2.1824% -2.0054% -1.8125%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe

To fold point/to_fold_point/1024
                        time:   [530.81 ns 531.30 ns 531.80 ns]
                        change: [-2.0295% -1.9054% -1.7716%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe
```

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-20 17:20:09 +00:00
committed by GitHub
parent b6fb1d0a19
commit d8f4293ac3
13 changed files with 332 additions and 206 deletions
+2 -3
View File
@@ -6140,9 +6140,8 @@ impl MultiBufferSnapshot {
} else if id == ExcerptId::max() {
Locator::max_ref()
} else {
let mut cursor = self.excerpt_ids.cursor::<ExcerptId>(());
cursor.seek(&id, Bias::Left);
if let Some(entry) = cursor.item()
let (_, _, item) = self.excerpt_ids.find::<ExcerptId, _>((), &id, Bias::Left);
if let Some(entry) = item
&& entry.id == id
{
return &entry.locator;