This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit d012d2f
committed
Auto merge of rust-lang#109399 - petrochenkov:rendersort, r=GuillaumeGomez
rustdoc: Optimize impl sorting during rendering
This should fix the perf regression on [bitmaps-3.1.0](https://github.com/rust-lang/rustc-perf/tree/master/collector/compile-benchmarks/bitmaps-3.1.0) from rust-lang#107765.
The bitmaps crate has a lot of impls:
```rust
impl Bits for BitsImpl<1> { ... }
impl Bits for BitsImpl<2> { ... }
// ...
impl Bits for BitsImpl<1023> { ... }
impl Bits for BitsImpl<1024> { ... }
```
and the logic in `fn print_item` sorts them in natural order.
Before rust-lang#107765 the impls came in source order, which happened to be already sorted in the necessary way.
So the comparison function was called fewer times.
After rust-lang#107765 the impls came in "stable" order (based on def path hash).
So the comparison function was called more times to sort them.
The comparison function was terribly inefficient, so it caused a large perf regression.
This PR attempts to make it more efficient by using cached keys during sorting.1 file changed
+20
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
883 | | - | |
884 | | - | |
| 883 | + | |
| 884 | + | |
885 | 885 | | |
886 | 886 | | |
887 | 887 | | |
| |||
1597 | 1597 | | |
1598 | 1598 | | |
1599 | 1599 | | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
| 1600 | + | |
| 1601 | + | |
1603 | 1602 | | |
1604 | | - | |
1605 | | - | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
1606 | 1619 | | |
1607 | 1620 | | |
1608 | 1621 | | |
| |||
0 commit comments