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

Installing docs with x.py install is very slow. #80684

Closed
vext01 opened this issue Jan 4, 2021 · 14 comments · Fixed by #84289
Closed

Installing docs with x.py install is very slow. #80684

vext01 opened this issue Jan 4, 2021 · 14 comments · Fixed by #84289
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Comments

@vext01
Copy link
Contributor

vext01 commented Jan 4, 2021

CC @pietroalbini

On today's git (0cd459f) x.py install seems to get stuck if you are building docs.

In config.toml:

[install]
prefix = "build/ykrustc-stage2-latest"
sysconfdir = "etc"

x.py install will get stuck at:

    Finished release [optimized] target(s) in 8.38s
Dist rust-docs-1.51.0-dev-x86_64-unknown-linux-gnu
        finished in 17.222 seconds
Install docs stage2 (Some(TargetSelection { triple: "x86_64-unknown-linux-gnu", file: None }))
install: creating uninstall script at /home/vext01/source/rust/build/tmp/empty_dir/build/ykrustc-stage2-latest/lib/rustlib/uninstall.sh
install: installing component 'rust-docs'

The underlying command is: sh /home/vext01/source/rust/build/tmp/tarball/rust-docs/x86_64-unknown-linux-gnu/rust-docs-1.51.0-dev-x86_64-unknown-linux-gnu/install.sh --prefix=/home/vext01/source/rust/build/ykrustc-stage2-latest --sysconfdir=build/ykrustc-stage2-latest/etc --datadir=build/ykrustc-stage2-latest/share --docdir=build/ykrustc-stage2-latest/share/doc/rust --bindir=build/ykrustc-stage2-latest/bin --libdir=build/ykrustc-stage2-latest/lib --mandir=build/ykrustc-stage2-latest/share/man --disable-ldconfig

Adding this to the config seems to work around the hang:

[build]
docs = false

Thanks!

@pietroalbini
Copy link
Member

How long did you let the command run before killing it? I remember installing the docs taking a long time last time I did it.

@vext01
Copy link
Contributor Author

vext01 commented Jan 4, 2021

I left it for half an hour or so IIRC. I'll run it for longer and see if it goes away.

How long do you think it should take to install on a modern SSD?

@pietroalbini
Copy link
Member

I don't remember exactly how long it takes, but it doesn't depend on the speed of the disk. install.sh is just really inefficient. You can see if it's actually hanging by checking the contents of lib/rustlib/install.log this command while it's installing:

tail -f build/ykrustc-stage2-latest/lib/rustlib/install.log

@vext01
Copy link
Contributor Author

vext01 commented Jan 4, 2021

The log file is empty, but I can see new files appearing on the disk (using find and diff) so progress must be occurring. Slowly.

@vext01
Copy link
Contributor Author

vext01 commented Jan 4, 2021

It's been about 40 minutes now. It seems to be adding files to build/tmp/empty_dir/ is that right?

@vext01
Copy link
Contributor Author

vext01 commented Jan 4, 2021

Build completed successfully in 0:57:44

So it's just very slow.

@vext01 vext01 changed the title x.py install hangs installing docs. Installing docs with x.py install is very slow. Jan 4, 2021
@jyn514 jyn514 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Jan 5, 2021
@jyn514
Copy link
Member

jyn514 commented Feb 14, 2021

I took a look into this. The main issue is that the generated install.sh is very inefficient; it takes about 5 minutes to copy 2500 files (there are more than 2500, but I got bored and cancelled it). @pietroalbini @Mark-Simulacrum what do you think about rewriting this inner loop in Rust so it's not launching so many external processes?

https://github.com/rust-lang/rust-installer/blob/5254dbfd25d5284728ab624dca1969d61427a0db/install-template.sh#L548

@daira
Copy link
Contributor

daira commented Mar 31, 2021

This issue is compounded on macOS, where it seems to be even more inefficient to launch lots of processes from a shell. Sorry I don't have timings, but it takes tens of minutes at least for this step [edit: over an hour]; long enough that I would expect most users who are trying to build our software from source in macOS (it's Zcash, which installs a pinned version of Rust in order to build) are likely to think it's hanging and give up.

@Mark-Simulacrum
Copy link
Member

I think the problem may largely be that the manifest.in generated for rust-docs component (at least) is a file: list instead of using the directory: command; directory commands should be much more efficient. This change may be a recent(ish) regression; I suspect that fixing that is likely the right solution here.

@jyn514
Copy link
Member

jyn514 commented Mar 31, 2021

what do you think about rewriting this inner loop in Rust so it's not launching so many external processes?

Oops I forgot to link back here: we discussed this briefly on Zulip and it was difficult to do in a cross-platform way.

@daira
Copy link
Contributor

daira commented Apr 1, 2021

We solved our problem for Zcash by just not installing rust-docs (passing --without=rust-docs to install.sh). This reduced our total build time on macOS from 95 minutes to 27 minutes! Obviously it doesn't solve the underlying issue.

@mbargull
Copy link

mbargull commented Apr 7, 2021

FYI, rust-lang/rust-installer#106 addresses this (not the underlying cause of the inefficiency but the majority of its extent).

@andersk
Copy link
Contributor

andersk commented Apr 12, 2021

I bisected the underlying issue to c768ce1 “bootstrap: convert rust-docs to use Tarball” (#79788).

Before this commit, rust-docs installs in half a second, and rust-docs/manifest.in is 1 line:

dir:share/doc/rust/html

After this commit, rust-docs installs in some twenty minutes, and rust-docs/manifest.in is 18742 lines:

file:share/doc/rust/html/rust.css
file:share/doc/rust/html/version_info.html
file:share/doc/rust/html/complement-design-faq.html
file:share/doc/rust/html/complement-lang-faq.html
file:share/doc/rust/html/complement-project-faq.html
file:share/doc/rust/html/guide-crates.html
file:share/doc/rust/html/guide-ffi.html
file:share/doc/rust/html/guide-macros.html
file:share/doc/rust/html/guide-strings.html
file:share/doc/rust/html/guide-tasks.html
…
file:share/doc/rust/html/rustc/fonts/source-code-pro-v11-all-charsets-500.woff2
file:share/doc/rust/html/rustc/searchindex.json
file:share/doc/rust/html/rustc/searchindex.js
file:share/doc/rust/html/rustc/searcher.js
file:share/doc/rust/html/rustc/mark.min.js
file:share/doc/rust/html/rustc/elasticlunr.min.js
file:share/doc/rust/html/rustc/images/image1.png
file:share/doc/rust/html/rustc/images/image2.png
file:share/doc/rust/html/rustc/images/image3.png
file:share/doc/rust/html/robots.txt

@andersk
Copy link
Contributor

andersk commented Apr 18, 2021

Proposed fix in #84289. (We should also do the optimization in rust-lang/rust-installer#106 of course.)

bors added a commit to rust-lang-ci/rust that referenced this issue Apr 22, 2021
…mulacrum

bootstrap: Restore missing --bulk-dirs for rust-docs, rustc-docs

The `--bulk-dirs` argument was removed for rust-docs in commit c768ce1 and rustc-docs in commit 8ca46fc (rust-lang#79788), presumably by mistake; that slowed down installation of rust-docs from under a second to some twenty *minutes*.  Restoring `--bulk-dirs` reverses this slowdown.

Fixes rust-lang#80684.

Cc `@pietroalbini.`
@bors bors closed this as completed in 6dfd700 Apr 22, 2021
gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue May 5, 2021
Bug: https://bugs.gentoo.org/783468
X-Upstream-Issue: rust-lang/rust#80684
X-Upstream-Fix: rust-lang/rust#84289
Package-Manager: Portage-3.0.18, Repoman-3.0.3
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants