Skip to content

compiletest: Default to one CGU when compiling tests. - #47779

Closed
michaelwoerister wants to merge 1 commit into
rust-lang:masterfrom
michaelwoerister:one-cgu-tests
Closed

compiletest: Default to one CGU when compiling tests.#47779
michaelwoerister wants to merge 1 commit into
rust-lang:masterfrom
michaelwoerister:one-cgu-tests

Conversation

@michaelwoerister

Copy link
Copy Markdown
Member

@aidanhs, maybe you want to give this a try. It reduced the execution time for run-pass from 8 min 30s to 7 min 5s on my machine (though that was just one test run, so ymmv).

r? @aidanhs

@kennytmkennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 26, 2018
@kennytm

Copy link
Copy Markdown
Member

So I've compare the timing of this PR against the master branch and two other unrelated PRs. It doesn't seem that there's any advantage on Travis CI's docker, in fact it becomes slower. Not sure about the performance on Windows and macOS.

Raw data

Table obtained by running grep -o 'travis_time:end.*,duration=\d*' log.txt | sed -E 's/travis_time:end:([^:]+):.*,duration=/\1,/g' on the raw log.

This PRBaseLatest MasterPR47676PR47795
stage0-std7859263911756126925920614079512075577333539088508007006
stage0-tidy80697062675978188129652392439260809324349231249361
tidy8821412470863616532470695249670936326404948499605234896
014a382289530948137648758978797077149834364589584858101343017616
stage0-std506807704512148301484436586531335308729745946
stage0-test1417850445710060915165112840573571010071808315421561879
stage0-rustc12233360584248950373504709864968814368941817451121362614163094
stage1-std7839479005051527984773545493720934997267885086937304360
stage1-test91007053456650431669753490515365929628549916295171
stage1-rustc850325923532651194815969705098789463639660365412926112982859
stage2-rustdoc242769346157167273952221183338663283164314134840260825835448
stage0-std602083657531937000490588091544782368612866768
stage0-test550248986519285731479952038525511956588994832
stage0-rustc588016315582316279506971373542125061635143822
stage1-std400062965369476021344442212367040959439905089
stage1-test338370964283825458269536938279705159351172083
stage1-rustc362387135328761079304789214319063830391863102
stage0-unstable-book-gen93899091217350250926750912758074577157009711786239
stage0-rustbook194348209994149244685365156009618060138917964783206108478026
stage2-rustdoc333367335310393875312372563318839760396061512
stage2-error_index_generator61712418705455658844497550052553902271346946201285
15a6031426981306481651991547690308216773379662719626254827402961879669122
stage0-std538180870553098090494893398540110862559174375
stage0-tidy12249987951152724207107025084311536117511430043736
tidy32896759783238393612317291077131972550043641671513
stage0-test495509436538088999495193128558052594583935524
stage0-rustc534236155562696420525732146580408644589073422
stage1-std379416863386725344354509989410555581412717342
stage1-test300324550388024562268296320305316634349206260
stage1-rustc350877033321157530313335068345958421388472157
build_test_helpers3978956436991921380141344454219945504121
stage0-compiletest2923268396021877335571243869129492136823529232966693304
test_ui107067559851853836102598880160411581974738153113915238131
test_run-pass125682487634491375675043910002761536879096436381821307968806619
test_compile-fail260608831800219306271300229404059545219981497561269970510702
test_parse-fail47072541934582241847468948202548227717355068159889
test_run-fail3332457797523023404433264795735162431024700035278977061
test_run-pass-valgrind51071066193749214697418809663339652299175488670634
test_mir-opt2818814565021191323568236729925142231804937728848061280
test_codegen1164629749578411874079127954896820776734412081372061
test_codegen-units1061586379969624169678076827466720767552110810972321
test_incremental8011656362651663715428578789551765423654650980414518509
test_debuginfo2842651626820814330120235500024902186071106730076909585
test_ui-fulldeps1878045331112810786528149903921281330146074219812676949
test_run-pass-fulldeps326221215724213864880964257864551246222446473076369155410000
test_run-fail-fulldeps35996334202311215595247871292723551096823459625347
test_compile-fail-fulldeps5460301277037106465415432782124693851142461756036911355
test_incremental-fulldeps64813075404598562186489106134047132576166992113421
stage2-rustdoc346880093294330006314503412300202641431475874
test_run-make1312268563188886650095010210269830192779566091133315798061
test_rustdoc200450251096149035748700177891240791152349722302220247137823
test_stage1-libstd10296863959876547164868067756251644076952883314391039390710264
test_stage1-libtest759826036052619073796251759053591574556712324680750
test_stage1-librustc220049426123153715524105178912343929160360240497241623770761
test_stage2-rustdoc4296560506029301018269330736425193059320469146241877515
stage0-unstable-book-gen540293225466071453501797031524692622604592056
stage0-rustbook547002605482647023511328950564230039600771757
stage2-error_index_generator327629660286363961293505793310137953384443462
stage0-linkchecker41116807273027848970332942282032455606304444792413
test_docs311036415452213191547593248141707395223573139716334901033360
test_error_index8745806670557046231936683102139635919043136888860845146
Normalized against total time taken for `make all`
This PRBaseLatest MasterPR47676PR47795
stage0-std5.8265.6375.6665.6845.976
stage0-tidy0.5980.6000.6020.6200.623
tidy6.5396.3896.4156.4476.726
014a38226.6376.5156.5306.5826.843
stage0-std0.0380.0510.0450.0540.049
stage0-test1.0511.0101.0411.0291.041
stage0-rustc90.68089.88491.01691.12192.010
stage1-std5.8115.1755.0335.0925.870
stage1-test0.6750.6680.6950.6720.670
stage1-rustc63.03165.39665.05465.18462.535
stage2-rustdoc17.99516.79816.91516.74417.612
stage0-std0.0450.0530.0450.0560.041
stage0-test0.0410.0520.0440.0540.040
stage0-rustc0.0440.0580.0470.0550.043
stage1-std0.0300.0370.0320.0370.030
stage1-test0.0250.0290.0250.0290.024
stage1-rustc0.0270.0330.0280.0330.026
stage0-unstable-book-gen0.6960.7380.6930.7600.656
stage0-rustbook14.40614.98814.39414.15613.917
stage2-rustdoc0.0250.0310.0290.0320.027
stage2-error_index_generator0.4570.5480.4590.5490.469
15a60314200.000200.000200.000200.000200.000
stage0-std0.0400.0560.0460.0550.038
stage0-tidy0.0910.1160.0990.1180.097
tidy0.2440.3250.2930.3260.246
stage0-test0.0370.0540.0460.0570.039
stage0-rustc0.0400.0570.0490.0590.040
stage1-std0.0280.0390.0330.0420.028
stage1-test0.0220.0390.0250.0310.024
stage1-rustc0.0260.0320.0290.0350.026
build_test_helpers0.0030.0040.0040.0050.003
stage0-compiletest2.1672.1972.2502.1782.226
test_ui7.9368.5758.1938.3547.692
test_run-pass93.16391.76392.28892.69788.320
test_compile-fail19.31822.02421.16522.41718.230
test_parse-fail0.3490.4600.4330.4910.342
test_run-fail2.4702.3122.4432.4772.382
test_run-pass-valgrind0.3790.3770.3860.4040.371
test_mir-opt2.0892.1282.1842.2741.948
test_codegen0.8630.7870.8420.8360.816
test_codegen-units0.7870.6990.7450.7340.730
test_incremental5.9395.1885.3405.5275.430
test_debuginfo2.1072.0902.1732.2282.031
test_ui-fulldeps1.3921.2871.3831.3551.338
test_run-pass-fulldeps24.18121.47723.79122.66824.927
test_run-fail-fulldeps0.2670.2320.2290.2400.234
test_compile-fail-fulldeps4.0473.7263.9933.9243.784
test_incremental-fulldeps0.4800.4620.4510.4800.472
stage2-rustdoc0.0260.0300.0290.0310.029
test_run-make9.7278.9249.4209.4559.002
test_rustdoc14.85814.96716.41315.52514.872
test_stage1-libstd76.32665.75071.56170.85370.185
test_stage1-libtest0.5630.5280.5770.6030.832
test_stage1-librustc16.31115.43716.50716.34116.316
test_stage2-rustdoc3.1852.9433.0513.1183.122
stage0-unstable-book-gen0.0400.0470.0460.0530.041
stage0-rustbook0.0410.0480.0470.0570.041
stage2-error_index_generator0.0240.0290.0270.0320.026
stage0-linkchecker0.3050.3040.3070.3310.300
test_docs23.05621.41022.89422.78322.614
test_error_index6.4835.7296.3026.0326.000

@kennytmkennytm added the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label Jan 31, 2018
@kennytm

Copy link
Copy Markdown
Member

Ping from triage @aidanhs! Do we want to try this?

@aidanhs

aidanhs commented Feb 3, 2018

Copy link
Copy Markdown
Contributor

Yeah I think so.

But - isn't codegen-units=1 the default for --release builds? I.e. we should combine this PR with #44675 to use codegen units for non-dist bots.

@aidanhs

Copy link
Copy Markdown
Contributor

I had lost track of what codegen-units is currently doing. After reading #45444 and #47834, I now see that codegen units are enabled for everything except beta/stable dist builds.

I'll try this locally in the next couple of weeks to see if I observe the similar speedups, in which case we can take a more careful look at why it slows travis down.

@shepmastershepmaster added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 9, 2018
@michaelwoerister

Copy link
Copy Markdown
MemberAuthor

This PR just leads to test being compiled with one codegen unit. The compiler is not affected.

If this doesn't make much of a difference, it's probably better to close this PR, since it will run tests in a non-default compiler mode.

@pnkfelix

Copy link
Copy Markdown
Contributor

@michaelwoerister what was your test platform where you observed the time go from 8m30s to 7m05s?

(the data that says "this makes no difference" was from linux, but that's not the primary build platform that we need to speed up anyway, is it?)

@michaelwoerister

Copy link
Copy Markdown
MemberAuthor

I tested on Ubuntu 16.04 with a 4C/8T CPU.

@arazabishov

Copy link
Copy Markdown

Ping from triage @aidanhs :) Did you have a chance to take a look why builds on travis are slowed down?

@aidanhs

Copy link
Copy Markdown
Contributor

I'm sorry, I didn't - give me another couple of days to give it a try :)

@aidanhs

Copy link
Copy Markdown
Contributor

I tried this locally via ./stamp ./x.py test --stage 1 src/test/run-pass on 16.04, 4C/8T CPU

  • with --disable-optimize (the default), the tests went from 221.195s to 192.175s
  • with --enable-optimize, the tests went from 271.008s to 198.000s

Definitely seems to make a difference. I had a thought though - codegen-units allows rustc itself to parallelise, and rust tests are run in parallel. Doesn't this mean that we're parallelising squared? Watching the load avg on my machine seems to confirm this - it hovers around 8 with this PR enabled (i.e. with codegen-units=1), but becomes at least double without it. Will do some more digging.

@michaelwoerister

Copy link
Copy Markdown
MemberAuthor

Doesn't this mean that we're parallelising squared?

Yes, that's one of the two main opportunities for saving time here. Splitting a program into multiple CGUs introduces some overhead but because we are already running so many compiler instances in parallel that additional overhead won't amortize itself.

The second reason one CGU might be faster for small programs (at least with --enable-optimize) is that we default to using ThinLTO, which again introduces overhead (and quite a bit of it) that can only be paid off by tapping into unused CPU cores. Since we already use all CPU cores we won't see any speedups.

However, I'm not sure how much we should change settings here from a test coverage perspective. Multiple CGUs and ThinLTO are the current defaults so I'm wary of running the test suite in a different mode.

@ishitatsuyuki

Copy link
Copy Markdown
Contributor

Doesn't this mean that we're parallelising squared?

Sounds like this is a valid usecase for #48532, but well disabling multiple CGUs works either.

@shepmaster

Copy link
Copy Markdown
Member

Ping from triage, @aidanhs !

@shepmaster

Copy link
Copy Markdown
Member

Gonna reassign to...

r? @kennytm

@rust-highfiverust-highfive assigned kennytm and unassigned aidanhsMar 23, 2018
@kennytm

Copy link
Copy Markdown
Member

@bors r+

Let's try this.

@bors

bors commented Mar 24, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 3ffa6da has been approved by kennytm

@borsbors 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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 24, 2018
@bors

bors commented Mar 24, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 3ffa6da with merge 1c1e3fa0c13d7b542bafb3b6401bbd57403d2cbc...

@bors

bors commented Mar 24, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-travis

@borsbors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 24, 2018
@borsbors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 24, 2018
@kennytm

Copy link
Copy Markdown
Member

Failed with wasm32-unknown-unknown 🤔

[01:05:58] failures:
[01:05:58] [01:05:58] ---- [run-pass] run-pass/issue-33992.rs stdout ----
[01:05:58] [01:05:58] error: compilation failed!
[01:05:58] status: signal: 6
[01:05:58] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass/issue-33992.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass" "--target=wasm32-unknown-unknown" "-Ccodegen-units=1" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-33992.stage2-wasm32-unknown-unknown.wasm" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/wasm32-unknown-unknown/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass/issue-33992.stage2-wasm32-unknown-unknown.aux"
[01:05:58] stdout:
[01:05:58] ------------------------------------------
[01:05:58] [01:05:58] ------------------------------------------
[01:05:58] stderr:
[01:05:58] ------------------------------------------
[01:05:58] Common symbols are not yet implemented for Wasm
[01:05:58] UNREACHABLE executed at /checkout/src/llvm/lib/MC/MCWasmStreamer.cpp:134!
[01:05:58] [01:05:58] ------------------------------------------
[01:05:58] [01:05:58] thread '[run-pass] run-pass/issue-33992.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2918:9
[01:05:58] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:05:58] [01:05:58] [01:05:58] failures:
[01:05:58] [run-pass] run-pass/issue-33992.rs

@kennytmkennytm 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 Mar 24, 2018
@shepmaster

Copy link
Copy Markdown
Member

Ping from triage, @michaelwoerister ! Will you have time to address the test failures?

@michaelwoerister

Copy link
Copy Markdown
MemberAuthor

I've actually come around to the opinion that we should not do this as it would cause our tests to be run in a non-standard compilation mode.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.T-infraRelevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@michaelwoerister@kennytm@aidanhs@pnkfelix@arazabishov@ishitatsuyuki@shepmaster@bors