about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-06-01 03:14:05 +0200
committerGitHub <noreply@github.com>2020-06-01 03:14:05 +0200
commitfa2943975a34f3705f869968b03c268be718e744 (patch)
tree504754c24fb928b10d5f510eeef901578e766ed7
parent0d93d3f4a42fd45b2a0da658d39555316a1b6793 (diff)
parent04417636945004b91de8e3f32ee10e80585d05ec (diff)
downloadrust-fa2943975a34f3705f869968b03c268be718e744.tar.gz
rust-fa2943975a34f3705f869968b03c268be718e744.zip
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
-rw-r--r--src/librustc_trait_selection/traits/fulfill.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/librustc_trait_selection/traits/fulfill.rs b/src/librustc_trait_selection/traits/fulfill.rs
index 252c84fba87..c1d9b0a2d88 100644
--- a/src/librustc_trait_selection/traits/fulfill.rs
+++ b/src/librustc_trait_selection/traits/fulfill.rs
@@ -75,9 +75,10 @@ pub struct FulfillmentContext<'tcx> {
 #[derive(Clone, Debug)]
 pub struct PendingPredicateObligation<'tcx> {
     pub obligation: PredicateObligation<'tcx>,
-    // FIXME(eddyb) look into whether this could be a `SmallVec`.
-    // Judging by the comment in `process_obligation`, the 1-element case
-    // is common so this could be a `SmallVec<[TyOrConstInferVar<'tcx>; 1]>`.
+    // This is far more often read than modified, meaning that we
+    // should mostly optimize for reading speed, while modifying is not as relevant.
+    //
+    // For whatever reason using a boxed slice is slower than using a `Vec` here.
     pub stalled_on: Vec<TyOrConstInferVar<'tcx>>,
 }