Repository navigation
Calculate Vec capacities in librustc - #52438
Conversation
This comment has been minimized.
This comment has been minimized.
|
r? @estebank |
This comment has been minimized.
This comment has been minimized.
|
Spurious error again; please retry. |
|
Retried. cc @nnethercote -- some of these are iterating over the data that'll be inserted into the vector to calculate the length; do you know off-hand if that's a bad idea or not? |
This comment has been minimized.
This comment has been minimized.
Not sure. If the data will be iterated over subsequently and it's not too large, it probably doesn't matter. Profiling is the ultimate test. (BTW, the PR lacks a description, as does the patch. That makes any kind of commentary more difficult. Even a single sentence of explanation would be helpful.) |
|
@nnethercote I added a short description (initially I just didn't think it was too informative); please advise if I'm missing anything. |
|
@ljedrz: Often the "why" is more interesting than the "what", especially for PRs and commit messages. Do you have measurements showing that this speeds things up? |
|
I'd be happy to measure it; could you tell me which benchmarks I should run and how to do it? I couldn't find that information online. |
|
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
@bors try Let's do a perf run I guess? |
Calculate Vec capacities in librustc Calculate the required capacity of a few vectors in rustc based on the number of elements they are populated with.
|
@oli-obk started an online perf run for you, but you can also do local benchmarking and profiling. Documentation is here: https://github.com/rust-lang-nursery/rustc-perf/tree/master/collector What prompted you to write this patch? It adds some complexity, and generally you'd want to have some other clear benefit to compensate. The default growth strategy for |
|
💔 Test failed - status-travis |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
I'll fix the error and do a perf run locally. |
0bb54a1 to
21956d3
Compare
|
Hmm, I can't build rust-perf due to I fixed the PR; @oli-obk can you try please? |
|
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
|
There was a problem hiding this comment.
This can be created from an iterator and .collect().
There was a problem hiding this comment.
This can be created from an iterator and .collect().
There was a problem hiding this comment.
This doesn't appear to be correct.
There was a problem hiding this comment.
It's later shrunk at 1380; processing keys() before the loop (which was in my initial commit) caused a really uninformative error to occur during stage 1 build.
There was a problem hiding this comment.
Then it's a better idea not to touch it at all. This is in the driver, and runs once per compilation, AFAICT, so it's not really worth optimizing (unless you can rewrite it to an iterator, that is).
There was a problem hiding this comment.
This can be created from an iterator and .collect().
|
In general we should really avoid |
|
@eddyb do you want these to be refactored to iterators + collect even if perf shows no benefits? (With the alternative being to close this PR) Otherwise I say we do a perf run and see if there's any point to doing this at all. |
|
☀️ Test successful - status-travis |
340e1ee to
4978a48
Compare
|
@eddyb I addressed your comments, does it look good now? |
There was a problem hiding this comment.
.and_then(|x| Some(y)) is always .map(|x| y) AFAIK
There was a problem hiding this comment.
Oh and you shouldn't need the *, using by-value Option methods will do it for you.
There was a problem hiding this comment.
Same thing here, and_then can be just map.
|
@rust-timer build 435ce0bad1c0bc79ec8f0591eba110a92492e6ff |
|
Success: Queued 435ce0bad1c0bc79ec8f0591eba110a92492e6ff with parent 0fc4501, comparison URL. |
4978a48 to
8a29409
Compare
|
@eddyb done. |
There was a problem hiding this comment.
You don't need the parens either, sorry I wasn't clear before.
There was a problem hiding this comment.
You're right, I should've noticed that; done.
8a29409 to
e3d14c4
Compare
|
@bors r+ Thanks! |
|
📌 Commit e3d14c4 has been approved by |
Calculate Vec capacities in librustc Calculate the required capacity of a few vectors in rustc based on the number of elements they are populated with.
|
☀️ Test successful - status-appveyor, status-travis |
Calculate the required capacity of a few vectors in rustc based on the number of elements they are populated with.