Skip to content

Commit

Permalink
Auto merge of #109399 - petrochenkov:rendersort, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
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/rust#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/rust#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/rust#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.
  • Loading branch information
bors committed Mar 24, 2023
2 parents f4894ff + a2e53fb commit 0d5c341
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 0d5c341

Please sign in to comment.