Skip to content

Commit fa29439

Browse files
authored
Rollup merge of #72776 - lcnr:stalled_on-smallvec, r=nnethercote
fulfill: try using SmallVec or Box for stalled_on Tested both `Box` and `SmallVec` for `stalled_on`, with both resulting in a perf loss. Adds a comment mentioning this and removes an now outdated FIXME. Logging the length of `stalled_on` resulted in the following distribution while building a part of stage 1 libs: ``` 22627647 counts: ( 1) 20983696 (92.7%, 92.7%): process_obligation_len: 1 ( 2) 959711 ( 4.2%, 97.0%): process_obligation_len: 2 ( 3) 682326 ( 3.0%,100.0%): process_obligation_len: 0 ( 4) 1914 ( 0.0%,100.0%): process_obligation_len: 3 ``` cc @eddyb r? @nnethercote
2 parents 0d93d3f + 0441763 commit fa29439

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/librustc_trait_selection/traits/fulfill.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ pub struct FulfillmentContext<'tcx> {
7575
#[derive(Clone, Debug)]
7676
pub struct PendingPredicateObligation<'tcx> {
7777
pub obligation: PredicateObligation<'tcx>,
78-
// FIXME(eddyb) look into whether this could be a `SmallVec`.
79-
// Judging by the comment in `process_obligation`, the 1-element case
80-
// is common so this could be a `SmallVec<[TyOrConstInferVar<'tcx>; 1]>`.
78+
// This is far more often read than modified, meaning that we
79+
// should mostly optimize for reading speed, while modifying is not as relevant.
80+
//
81+
// For whatever reason using a boxed slice is slower than using a `Vec` here.
8182
pub stalled_on: Vec<TyOrConstInferVar<'tcx>>,
8283
}
8384

0 commit comments

Comments
 (0)