# Optimize construction and insertion of large \`SumTree\`s \(\#7731\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/33f713a8ab89bede6ce6e2c92a29c2f42486fcb5)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 33f713a8ab89bede6ce6e2c92a29c2f42486fcb5

Requested commit: 33f713a8ab89bede6ce6e2c92a29c2f42486fcb5

Commit: 33f713a8ab89bede6ce6e2c92a29c2f42486fcb5

Tree: 2a34b38efeaaa9bdcaba6c0e78d414704d182f68

Author: Thorsten Ball

Committer: GitHub

## Message

```
Optimize construction and insertion of large `SumTree`s (#7731)

This does two things:

1. It optimizes the constructions of `SumTree`s to not insert nodes
one-by-one, but instead inserts them level-by-level. That makes it more
efficient to construct large `SumTree`s.
2. It adds a `from_par_iter` constructor that parallelizes the
construction of `SumTree`s.

In combination, **loading a 500MB plain text file went from from
~18seconds down to ~2seconds**.

Disclaimer: I didn't write any of this code, lol! It's all @as-cii and
@nathansobo.

Release Notes:

- Improved performance when opening very large files.

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Julia <julia@zed.dev>
```

## Parents

- [798c9a7d8b32d40dec07788ca85bf5141409547b](https://git.cafe/gitcafe/zed/commit/798c9a7d8b32d40dec07788ca85bf5141409547b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/33f713a8ab89bede6ce6e2c92a29c2f42486fcb5?format=markdown)
