Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTry to guess a smarter initial capacity in Vec::from_iter #53086
Conversation
rust-highfive
assigned
kennytm
Aug 5, 2018
This comment has been minimized.
This comment has been minimized.
|
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
label
Aug 5, 2018
This comment has been minimized.
This comment has been minimized.
|
This is potentially awesome not only for |
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
kennytm
added
the
S-waiting-on-perf
label
Aug 5, 2018
bors
added a commit
that referenced
this pull request
Aug 5, 2018
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@rust-timer build 8612aa2 |
This comment has been minimized.
This comment has been minimized.
rust-timer
commented
Aug 5, 2018
|
Success: Queued 8612aa2 with parent b47c314, comparison URL. |
This comment has been minimized.
This comment has been minimized.
|
Perf is ready. |
kennytm
removed
the
S-waiting-on-perf
label
Aug 6, 2018
This comment has been minimized.
This comment has been minimized.
|
Some greens, some reds... I'd say the results are inconclusive |
This comment has been minimized.
This comment has been minimized.
|
Hmm, for instructions things seem slightly worse overall :( How reliable are the time measurements? It's interesting that webrender-clean-opt is +0.3% for instructions:u, but -1.5% for wall-time. (Another thing that surprised me: max-rss -3.5% for webrender-debug-clean.) I think I'll try something less complicated than the sqrt approximation for the guess; maybe it's just not worth doing that work and making LLVM compile it when people use Vec, even though it's simple integer instructions. (It's less and less helpful the larger the gap anyway.) |
kennytm
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Aug 7, 2018
scottmcm
added some commits
Aug 5, 2018
scottmcm
force-pushed the
scottmcm:use-upper-in-collect
branch
from
fe30b5b
to
aa080f4
Aug 8, 2018
This comment has been minimized.
This comment has been minimized.
|
Ok, I've pushed a much simpler change that's only targeted at one side of the problem. Could I get another try+perf run to see whether it's fruitful overall, please? |
This comment has been minimized.
This comment has been minimized.
|
@bors try |
This comment has been minimized.
This comment has been minimized.
kennytm
added
S-waiting-on-review
S-waiting-on-perf
and removed
S-waiting-on-author
labels
Aug 8, 2018
bors
added a commit
that referenced
this pull request
Aug 8, 2018
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@rust-timer build 68f1266 |
This comment has been minimized.
This comment has been minimized.
rust-timer
commented
Aug 8, 2018
|
Success: Queued 68f1266 with parent 26d7b64, comparison URL. |
This comment has been minimized.
This comment has been minimized.
|
Perf is ready. |
kennytm
removed
the
S-waiting-on-perf
label
Aug 9, 2018
This comment has been minimized.
This comment has been minimized.
|
Hmm, that's again a bit too mixed for me to be happy about. I'll just close this. Anyone interested should feel free to pick this space up again; feel free to use or ignore anything I did in this PR |
scottmcm commentedAug 5, 2018
This is obviously good for hints like
(60, Some(61))where today we allocate space for 60, then double it should the additional element show up, and it'd be much better to just always allocate 61.More nuanced are hints like
(0, Some(150)), where today the code uses just the0, and thus starts at a capacity of1, but with this change will start at10instead.This can undeniably increase memory pressure over where it is today, so I expect at least some controversy🙂 It does use
try_reservefor the allocation that's more than the lower bound, and thus shouldn't introduce new aborts, at least. And the starting point grows by the root, keeping things fairly contained: even with an hint of(0, Some(1_000_000_000))it'll only start at30_517.cc @ljedrz
cc #48994