Skip to content

Calculate Vec capacities in librustc - #52438

Merged
bors merged 1 commit into
rust-lang:masterfrom
ljedrz:rustc_vec_capacity
Jul 21, 2018
Merged

bors merged 1 commit into
rust-lang:masterfrom
ljedrz:rustc_vec_capacity

Conversation

@ljedrz

@ljedrz ljedrz commented Jul 16, 2018 •

Copy link
Copy Markdown
Contributor

Calculate the required capacity of a few vectors in rustc based on the number of elements they are populated with.

@rust-highfive

This comment has been minimized.

@rust-lang rust-lang deleted a comment from rust-highfive Jul 16, 2018
@XAMPPRocky

Copy link
Copy Markdown
Contributor

r? @estebank

@rust-highfive

This comment has been minimized.

@XAMPPRocky XAMPPRocky added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 16, 2018
@ljedrz

ljedrz commented Jul 16, 2018 •

Copy link
Copy Markdown
Contributor Author

Spurious error again; please retry.

@Mark-Simulacrum

Copy link
Copy Markdown
Member

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?

@rust-highfive

This comment has been minimized.

@nnethercote

Copy link
Copy Markdown
Contributor

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?

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.)

@ljedrz

ljedrz commented Jul 16, 2018

Copy link
Copy Markdown
Contributor Author

@nnethercote I added a short description (initially I just didn't think it was too informative); please advise if I'm missing anything.

@rust-lang rust-lang deleted a comment from rust-highfive Jul 16, 2018
@rust-lang rust-lang deleted a comment from rust-highfive Jul 16, 2018
@nnethercote

Copy link
Copy Markdown
Contributor

@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?

@ljedrz

ljedrz commented Jul 17, 2018

Copy link
Copy Markdown
Contributor Author

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.

@rust-highfive

Copy link
Copy Markdown
Contributor

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 @TimNN. (Feature Requests)

@oli-obk

oli-obk commented Jul 17, 2018

Copy link
Copy Markdown
Contributor

@bors try

Let's do a perf run I guess?

@bors

bors commented Jul 17, 2018

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 0bb54a1 with merge 07079a7...

bors added a commit that referenced this pull request Jul 17, 2018
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.
@nnethercote

Copy link
Copy Markdown
Contributor

@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 Vec is usually reasonable. Going to the effort of precomputing a length like this is usually only worthwhile if the number of Vecs created is large, or the Vecs themselves have many elements.

@bors

bors commented Jul 17, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-travis

@rust-highfive

Copy link
Copy Markdown
Contributor

The job dist-x86_64-linux of 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.
travis_fold:end:services

travis_fold:start:git.checkout
travis_time:start:1691dd16
$ git clone --depth=2 --branch=try https://github.com/rust-lang/rust.git rust-lang/rust
---
[00:18:51]    Compiling rustc_borrowck v0.0.0 (file:///checkout/src/librustc_borrowck)
[00:18:51]    Compiling rustc_passes v0.0.0 (file:///checkout/src/librustc_passes)
[00:19:11]    Compiling rustc_codegen_utils v0.0.0 (file:///checkout/src/librustc_codegen_utils)
[00:19:24]    Compiling rustc_lint v0.0.0 (file:///checkout/src/librustc_lint)
[00:19:35] error[E0599]: no method named `iter` found for type `std::collections::btree_map::Keys<'_, rustc::session::config::OutputType, std::option::Option<std::path::PathBuf>>` in the current scope
[00:19:35]     --> librustc_driver/driver.rs:1358:22
[00:19:35]      |
[00:19:35] 1358 |         output_types.iter().fold(0, |acc, ot| acc +
[00:19:35] 
[00:19:35] error: aborting due to previous error
[00:19:35] 
[00:19:35] For more information about this error, try `rustc --explain E0599`.
[00:19:35] For more information about this error, try `rustc --explain E0599`.
[00:19:35] error: Could not compile `rustc_driver`.
[00:19:35] 
[00:19:35] Caused by:
[00:19:35]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_driver librustc_driver/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=f7646c9abc3d02c6 -C extra-filename=-f7646c9abc3d02c6 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=clang -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-6d643f75b30009ec.so --extern env_logger=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libenv_logger-0a93173f03a79b8d.rlib --extern graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libgraphviz-09a8465c475acbfe.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-96863e4e4a7d8742.rlib --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-50b4354a63d955e7.so --extern rustc_rayon=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_rayon-37c946810bf339eb.rlib --extern rustc_allocator=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_allocator-a22f5323a757a1a5.so --extern rustc_borrowck=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_borrowck-0b78be5e49495de3.so --extern rustc_codegen_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_codegen_utils-ddfd7bb605afc401.so --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-7b2393552f7c05ab.so --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-5a587f583bd26ea0.so --extern rustc_incremental=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_incremental-1f45a21db1899b6d.so --extern rustc_lint=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_lint-0c6a22e4bf4525d1.so --extern rustc_metadata=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_metadata-e2cdb405d3015fe5.so --extern rustc_mir=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_mir-beaee3be21b57d8d.so --extern rustc_passes=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_passes-c5404bfc39dae280.so --extern rustc_plugin=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_plugin-981f27df1cd6e3a9.so --extern rustc_privacy=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_privacy-bfec5ac3788190b9.so --extern rustc_resolve=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_resolve-2a478c753fc3f86e.so --extern rustc_save_analysis=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_save_analysis-75820b40cd20d4fd.so --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-5aa06a687b1a439d.so --extern rustc_traits=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_traits-b246e0e47fc183bc.so --extern rustc_typeck=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_typeck-486be882e192b694.so --extern scoped_tls=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libscoped_tls-2d0488f0587a9fe8.rlib --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5615a04cb21f88e7.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5615a04cb21f88e7.rlib --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-4f33c70c5f92f8b7.so --extern syntax_ext=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_ext-5a0613786e04edc1.so --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-4e87684380615cae.so -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-fcd4d8eb5dc11f1a/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-571491b5b700df39/out` (exit code: 101)

[00:19:35] travis_time:end:stage0-rustc:start=1531808415710893194,finish=1531809214704997753,duration=798994104559

[00:19:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
[00:19:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
[00:19:35] Build completed unsuccessfully in 0:14:18
[00:19:35] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:19:35] expected success, got: exit code: 101
[00:19:35] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1119:9
travis_time:end:02ebf96f:start=1531808039214594879,finish=1531809214969628033,duration=1175755033154

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 1.
travis_time:start:04a045ee
---
travis_time:end:061379ae:start=1531809215287034224,finish=1531809215293549675,duration=6515451
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00207a5f
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:02571af6
travis_time:start:02571af6
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1ecec07f
$ dmesg | grep -i kill

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 @TimNN. (Feature Requests)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 17, 2018
@rust-highfive

Copy link
Copy Markdown
Contributor

The job dist-x86_64-linux of 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.
travis_fold:end:services

travis_fold:start:git.checkout
travis_time:start:1691dd16
$ git clone --depth=2 --branch=try https://github.com/rust-lang/rust.git rust-lang/rust
---
[00:18:51]    Compiling rustc_borrowck v0.0.0 (file:///checkout/src/librustc_borrowck)
[00:18:51]    Compiling rustc_passes v0.0.0 (file:///checkout/src/librustc_passes)
[00:19:11]    Compiling rustc_codegen_utils v0.0.0 (file:///checkout/src/librustc_codegen_utils)
[00:19:24]    Compiling rustc_lint v0.0.0 (file:///checkout/src/librustc_lint)
[00:19:35] error[E0599]: no method named `iter` found for type `std::collections::btree_map::Keys<'_, rustc::session::config::OutputType, std::option::Option<std::path::PathBuf>>` in the current scope
[00:19:35]     --> librustc_driver/driver.rs:1358:22
[00:19:35]      |
[00:19:35] 1358 |         output_types.iter().fold(0, |acc, ot| acc +
[00:19:35] 
[00:19:35] error: aborting due to previous error
[00:19:35] 
[00:19:35] For more information about this error, try `rustc --explain E0599`.
[00:19:35] For more information about this error, try `rustc --explain E0599`.
[00:19:35] error: Could not compile `rustc_driver`.
[00:19:35] 
[00:19:35] Caused by:
[00:19:35]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_driver librustc_driver/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=f7646c9abc3d02c6 -C extra-filename=-f7646c9abc3d02c6 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=clang -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-6d643f75b30009ec.so --extern env_logger=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libenv_logger-0a93173f03a79b8d.rlib --extern graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libgraphviz-09a8465c475acbfe.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-96863e4e4a7d8742.rlib --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-50b4354a63d955e7.so --extern rustc_rayon=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_rayon-37c946810bf339eb.rlib --extern rustc_allocator=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_allocator-a22f5323a757a1a5.so --extern rustc_borrowck=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_borrowck-0b78be5e49495de3.so --extern rustc_codegen_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_codegen_utils-ddfd7bb605afc401.so --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-7b2393552f7c05ab.so --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-5a587f583bd26ea0.so --extern rustc_incremental=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_incremental-1f45a21db1899b6d.so --extern rustc_lint=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_lint-0c6a22e4bf4525d1.so --extern rustc_metadata=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_metadata-e2cdb405d3015fe5.so --extern rustc_mir=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_mir-beaee3be21b57d8d.so --extern rustc_passes=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_passes-c5404bfc39dae280.so --extern rustc_plugin=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_plugin-981f27df1cd6e3a9.so --extern rustc_privacy=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_privacy-bfec5ac3788190b9.so --extern rustc_resolve=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_resolve-2a478c753fc3f86e.so --extern rustc_save_analysis=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_save_analysis-75820b40cd20d4fd.so --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-5aa06a687b1a439d.so --extern rustc_traits=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_traits-b246e0e47fc183bc.so --extern rustc_typeck=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_typeck-486be882e192b694.so --extern scoped_tls=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libscoped_tls-2d0488f0587a9fe8.rlib --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5615a04cb21f88e7.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5615a04cb21f88e7.rlib --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-4f33c70c5f92f8b7.so --extern syntax_ext=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_ext-5a0613786e04edc1.so --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-4e87684380615cae.so -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-fcd4d8eb5dc11f1a/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-571491b5b700df39/out` (exit code: 101)

[00:19:35] travis_time:end:stage0-rustc:start=1531808415710893194,finish=1531809214704997753,duration=798994104559

[00:19:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
[00:19:35] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
[00:19:35] Build completed unsuccessfully in 0:14:18
[00:19:35] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:19:35] expected success, got: exit code: 101
[00:19:35] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1119:9
travis_time:end:02ebf96f:start=1531808039214594879,finish=1531809214969628033,duration=1175755033154

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 1.
travis_time:start:04a045ee
---
travis_time:end:061379ae:start=1531809215287034224,finish=1531809215293549675,duration=6515451
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00207a5f
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:02571af6
travis_time:start:02571af6
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1ecec07f
$ dmesg | grep -i kill

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 @TimNN. (Feature Requests)

@ljedrz

ljedrz commented Jul 17, 2018

Copy link
Copy Markdown
Contributor Author

I'll fix the error and do a perf run locally.

@ljedrz
ljedrz force-pushed the rustc_vec_capacity branch from 0bb54a1 to 21956d3 Compare July 17, 2018 07:32
@ljedrz

ljedrz commented Jul 17, 2018

Copy link
Copy Markdown
Contributor Author

Hmm, I can't build rust-perf due to

error[E0425]: cannot find function `exec` in this scope
   --> collector\src/bin/rustc-fake.rs:139:9
    |
139 |         exec(&mut cmd);
    |         ^^^^ not found in this scope

I fixed the PR; @oli-obk can you try please?

@rust-highfive

Copy link
Copy Markdown
Contributor

The job x86_64-gnu-llvm-5.0 of 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.
[00:17:56]    Compiling rustc_lsan v0.0.0 (file:///checkout/src/librustc_lsan)
[00:17:57]    Compiling rustc_tsan v0.0.0 (file:///checkout/src/librustc_tsan)
[00:17:57]    Compiling rustc_asan v0.0.0 (file:///checkout/src/librustc_asan)
[00:17:58]    Compiling rustc_msan v0.0.0 (file:///checkout/src/librustc_msan)
[00:18:42] error: could not parse/generate dep info at: /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/core-1cbcabaa1ea822b5.d
[00:18:42] To learn more, run the command again with --verbose.
[00:18:42] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
[00:18:42] expected success, got: exit code: 101
[00:18:42] expected success, got: exit code: 101
[00:18:42] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1119:9
[00:18:42] travis_fold:end:stage1-std

[00:18:42] travis_time:end:stage1-std:start=1531813986336194463,finish=1531814042293753182,duration=55957558719


[00:18:42] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:18:42] Build completed unsuccessfully in 0:15:06
[00:18:43] make: *** [all] Error 1
[00:18:43] Makefile:28: recipe for target 'all' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:122c7394
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:22a1ec40:start=1531814042867792741,finish=1531814042874915860,duration=7123119
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:15573fcc
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:11b9ca10
travis_time:start:11b9ca10
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0a73083e
$ dmesg | grep -i kill

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 @TimNN. (Feature Requests)

@ljedrz

ljedrz commented Jul 17, 2018

Copy link
Copy Markdown
Contributor Author

[00:18:42] error: could not parse/generate dep info at: /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/core-1cbcabaa1ea822b5.d 😕?

Comment thread src/librustc/middle/dead.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be created from an iterator and .collect().

Comment thread src/librustc/infer/mod.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be created from an iterator and .collect().

Comment thread src/librustc_driver/driver.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread src/librustc_typeck/astconv.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be created from an iterator and .collect().

@eddyb

eddyb commented Jul 19, 2018

Copy link
Copy Markdown
Contributor

In general we should really avoid Vec::with_capacity, and push calls, if we can use iterators.

@oli-obk

oli-obk commented Jul 19, 2018 •

Copy link
Copy Markdown
Contributor

@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.

@bors

bors commented Jul 19, 2018

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-travis
State: approved= try=True

@ljedrz
ljedrz force-pushed the rustc_vec_capacity branch from 340e1ee to 4978a48 Compare July 20, 2018 14:35
@ljedrz

ljedrz commented Jul 20, 2018 •

Copy link
Copy Markdown
Contributor Author

@eddyb I addressed your comments, does it look good now?

Comment thread src/librustc/middle/dead.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.and_then(|x| Some(y)) is always .map(|x| y) AFAIK

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and you shouldn't need the *, using by-value Option methods will do it for you.

Comment thread src/librustc_codegen_llvm/abi.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use map and sum.

Comment thread src/librustc_typeck/astconv.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, and_then can be just map.

@kennytm

kennytm commented Jul 20, 2018

Copy link
Copy Markdown
Member

@rust-timer build 435ce0bad1c0bc79ec8f0591eba110a92492e6ff

@rust-timer

Copy link
Copy Markdown
Collaborator

Success: Queued 435ce0bad1c0bc79ec8f0591eba110a92492e6ff with parent 0fc4501, comparison URL.

@kennytm kennytm added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 20, 2018
@ljedrz
ljedrz force-pushed the rustc_vec_capacity branch from 4978a48 to 8a29409 Compare July 20, 2018 18:06
@ljedrz

ljedrz commented Jul 20, 2018

Copy link
Copy Markdown
Contributor Author

@eddyb done.

Comment thread src/librustc/middle/dead.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the parens either, sorry I wasn't clear before.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I should've noticed that; done.

@ljedrz
ljedrz force-pushed the rustc_vec_capacity branch from 8a29409 to e3d14c4 Compare July 20, 2018 20:02
@eddyb

eddyb commented Jul 20, 2018

Copy link
Copy Markdown
Contributor

@bors r+ Thanks!

@bors

bors commented Jul 20, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit e3d14c4 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 20, 2018
@bors

bors commented Jul 21, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e3d14c4 with merge bf7afee...

bors added a commit that referenced this pull request Jul 21, 2018
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.
@bors

bors commented Jul 21, 2018

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing bf7afee to master...

@bors
bors merged commit e3d14c4 into rust-lang:master Jul 21, 2018
@ljedrz
ljedrz deleted the rustc_vec_capacity branch July 21, 2018 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-perf Status: Waiting on a perf run to be completed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.