Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc disregards job limit #53143

Open
ilammy opened this issue Aug 7, 2018 · 5 comments
Open

rustdoc disregards job limit #53143

ilammy opened this issue Aug 7, 2018 · 5 comments
Labels
A-doctests Area: Documentation tests, run by rustdoc A-libtest Area: `#[test]` / the `test` library T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ilammy
Copy link
Contributor

ilammy commented Aug 7, 2018

When running doctests (via cargo doc or cargo test) rustdoc will compile each doctest separately, keeping a queue of compilation jobs. Maximum size of the queue seems to be limited to the number of CPUs in the system, but there seems to be no way to adjust that via command line or other configuration (--jobs N is ignored, for example).

This is particularly nasty on my laptop with 8 CPUs and only 8 GB of RAM that are quickly consumed by eight linkers running in parallel with all other stuff. Lying to rustdoc about CPU count by hooking sysconf() helps as a workaround, but this is hardly an elegant solution.

@ilammy ilammy changed the title rustdoc has disregards job limit rustdoc disregards job limit Aug 7, 2018
@Mark-Simulacrum Mark-Simulacrum added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. I-nominated labels Aug 7, 2018
@Mark-Simulacrum
Copy link
Member

This might be having a detrimental impact on our Travis builders as well so I've nominated, presumably the fix is relatively straightforward.

@QuietMisdreavus
Copy link
Member

Rustdoc runs the compilation as part of the test, and leaves coordination to the test runner - it doesn't synchronize anything on top of it. You can control the amount of concurrent tests with the --test-threads flag, like this:

$ cargo test --doc -- --test-threads 1

@QuietMisdreavus QuietMisdreavus added A-libtest Area: `#[test]` / the `test` library A-doctests Area: Documentation tests, run by rustdoc labels Nov 6, 2018
@jyn514
Copy link
Member

jyn514 commented Nov 6, 2020

Rustdoc can't fix this on its end, cargo doesn't pass it the number of jobs:

   Doc-tests log
     Running `rustdoc --crate-type lib --test /home/joshua/src/rust/log/src/lib.rs --crate-name log -L dependency=/home/joshua/.local/lib/cargo/target/debug/deps -L dependency=/home/joshua/.local/lib/cargo/target/debug/deps --cfg const_type_id --cfg atomic_cas --cfg has_atomics --cfg srcbuild --extern cfg_if=/home/joshua/.local/lib/cargo/target/debug/deps/libcfg_if-78e41e584d7442e1.rlib --extern log=/home/joshua/.local/lib/cargo/target/debug/deps/liblog-317dcbf283c962fd.rlib --extern serde_test=/home/joshua/.local/lib/cargo/target/debug/deps/libserde_test-3647946855f36b77.rlib --extern sval=/home/joshua/.local/lib/cargo/target/debug/deps/libsval-0040d76711c48027.rlib -C embed-bitcode=no`

Maybe cargo should pass through --jobs as --test-threads? But that's a cargo issue.

@jyn514 jyn514 removed the I-nominated label Nov 6, 2020
@donpellegrino
Copy link

Rustdoc can't fix this on its end, cargo doesn't pass it the number of jobs:

   Doc-tests log
     Running `rustdoc --crate-type lib --test /home/joshua/src/rust/log/src/lib.rs --crate-name log -L dependency=/home/joshua/.local/lib/cargo/target/debug/deps -L dependency=/home/joshua/.local/lib/cargo/target/debug/deps --cfg const_type_id --cfg atomic_cas --cfg has_atomics --cfg srcbuild --extern cfg_if=/home/joshua/.local/lib/cargo/target/debug/deps/libcfg_if-78e41e584d7442e1.rlib --extern log=/home/joshua/.local/lib/cargo/target/debug/deps/liblog-317dcbf283c962fd.rlib --extern serde_test=/home/joshua/.local/lib/cargo/target/debug/deps/libserde_test-3647946855f36b77.rlib --extern sval=/home/joshua/.local/lib/cargo/target/debug/deps/libsval-0040d76711c48027.rlib -C embed-bitcode=no`

Maybe cargo should pass through --jobs as --test-threads? But that's a cargo issue.

Has a cargo issue already been filed for this?

@weihanglo
Copy link
Member

See also rust-lang/cargo#10702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: Documentation tests, run by rustdoc A-libtest Area: `#[test]` / the `test` library T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
Status: No status
Development

No branches or pull requests

6 participants