about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/query.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-28 12:22:17 +0000
committerbors <bors@rust-lang.org>2024-08-28 12:22:17 +0000
commit9ad0f65049ae4d7ddc15a512d8ab2b0ac7f035e5 (patch)
treeb3e954fd5e468457db6e73729ed88197b8ea297a /compiler/rustc_mir_transform/src/coverage/query.rs
parent79115f538aca805455d6c207d8870dee884c63f3 (diff)
parent84134c61bc4e616bf144bb8498810df2bf7a48e4 (diff)
downloadrust-9ad0f65049ae4d7ddc15a512d8ab2b0ac7f035e5.tar.gz
rust-9ad0f65049ae4d7ddc15a512d8ab2b0ac7f035e5.zip
Auto merge of #3837 - JoJoDeveloping:tb-compacting-provenance-gc, r=RalfJung
Make Tree Borrows Provenance GC compact the tree

Follow-up on #3833 and #3835. In these PRs, the TB GC was fixed to no longer cause a stack overflow. One test that motivated it was the test `fill::horizontal_line` in [`tiny-skia`](https://github.com/RazrFalcon/tiny-skia). But not causing stack overflows was not a large improvents, since it did not fix the fundamental issue: The tree was too large. The test now ran, but it required gigabytes of memory and hours of time (only for it to be OOM-killed 🤬), whereas it finishes within 24 seconds in Stacked Borrows. With this merged, it finishes in about 40 seconds under TB.

The problem in that test was that it used [`slice::chunked`](https://doc.rust-lang.org/std/primitive.slice.html#method.chunks) to iterate a slice in chunks. That iterator is written to reborrow at each call to `next`, which creates a linear tree with a bunch of intermediary nodes, which also fragments the `RangeMap` for that allocation.

The solution is to now compact the tree, so that these interior nodes are removed. Care is taken to not remove nodes that are protected, or that otherwise restrict their children.

I am currently only 99% sure that this is sound, and I do also think that this could compact even more. So `@Vanille-N` please also have a look at whether I got the compacting logic right.

For a more visual comparison, [here is a gist](https://gist.github.com/JoJoDeveloping/ae4a7f7c29335a4c233ef42d2f267b01) of what the tree looks like at one point during that test, with and without compacting.

This new GC requires a different iteration order during accesses (since the current one can make the error messages non-deterministic), so it is rebased on top of #3843 and requires that PR to be merged first.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/query.rs')
0 files changed, 0 insertions, 0 deletions