Avoid TrustedLen specialization that optimize poorly in collect_remaining_errors - #160073
Avoid TrustedLen specialization that optimize poorly in collect_remaining_errors#160073panstromek wants to merge 1 commit into
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Avoid TrustedLen specialization that optimize poorly in collect_remaining_errors
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (4bd0be6): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -1.1%, secondary -2.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.5%, secondary -2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 490.165s -> 488.452s (-0.35%) |
|
Yea, the issue is still there even after #160005. r? @nnethercote Atm I don't know if we will be able to fix the |
|
Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor |
|
Is this an error codepath? Why are we hitting it that much in the benchmarks? |
|
Probably because our benchmarks are relatively old crates (anything gets old quickly in Rust unless you regularly update it), and they are generating thousands of warnings, FCWs, etc. Edit: wait, this looks like an actual trait error codepath? Not sure if that is relevant to what I wrote above; if not, then nevermind. |
|
It seems that way although I haven't checked. But if there's anything in there it looks like a bad time heh. I'm mostly pointing this out so we know what we're optimizing, if it's worth it, and the opposite (the regressions we could sometimes ignore in the other PRs working with ThinVec). |
|
I'm not sure, I assumed it's one of those things where we try to solve something multiple ways until it succeeds, so the error happens as a part of normal execution path. But if the list is always empty, then it'd kinda make sense that an iterator that doesn't look at |
|
It is indeed almost always empty, but sometimes not: $ cat results/eprintln-Id-syn-2.0.101-new-solver-Check-Full | sort | uniq -c | sort -n
182 collect_remaining_errors: len=1
1057538 collect_remaining_errors: len=0 |
|
Maybe the size hint is set based on capacity or something? That is weird, I would expect that if the input Vec is empty, then the size hint will also be set to 0. Anyway, maybe instead of the |
Maybe. Trustedlen is, well, trusted, so perhaps we can shortcircuit on 0 there too. OTOH that's an extra branch, so it'll need benchmarking. |
It should be exactly the length of the iterator (and therefore But to clarify what I was talking about, the non-specialized impl first calls They are right next to each other here: https://github.com/rust-lang/rust/blob/main/library/alloc/src/vec/spec_from_iter_nested.rs But yea, I might actually just add |
Heh, yes and no. Those are the FromIterator entrypoints, which then delegates two its another maze of Extend specializations, which bottom out here, also next to each other: rust/library/alloc/src/vec/mod.rs Lines 4099 to 4155 in e19d321 |
What does this mean? Google didn't give me any answers that seem relevant :) |
|
Sorry, it means something like "guess from cursory look." or a "guesstimate." Vočko means something like a squinting eye. |
53b006c to
51752f0
Compare
|
Thanks. I addressed the nits but I don't have r+ rights. |
|
@bors r+ |
View all comments
see #160048