-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Cargo keeps entire rustc/rustdoc stdout in memory #6197
Comments
I disagree. We don't have buffering yet, and yes if buffering is implemented your solution address a part of the problem. The problem is simply that we don't have backpressure for consuming logs as we use an unbounded Fix: make this bounded. cargo/src/cargo/core/compiler/job_queue.rs Line 135 in 2d0863f
|
@ishitatsuyuki: This did come up for real - setting |
I think there are multiple issues here. Simple commands like During the normal compile execution, even though the output is streamed to the terminal, internally it buffers the entire result here. This is used in a few cases (like capturing build script output), but for the case of running |
I think the correct fix here is to have Cargo discard rustc's output when it otherwise doesn't need to capture it, and I think that should be relatively easy to do? |
Avoid retaining all rustc output in memory. There are still a few cases where all output is buffered. They are: - Running discovery commands like `rustc -vV`, `rustc --print xxx`, etc. - Build script output. - Testsuite's debug `.stream()` function. This should cover the concern of the issue, though, which is normal compilation. Closes #6197
This issue is back - I haven't managed to find a minimized reproduction yet, but building the compiler with |
Can this issue be re-opened? I've run into this again today, and it's making debugging quite difficult. |
This must have slipped into beta. Reopening; we might want to try and backport my PR to beta I guess? |
Considering the release is in two weeks, can it wait? @Aaron1011, would it be possible to confirm that it is fixed? Set |
@ehuss: I can't seem to get rustup to use the newer version: |
I'm not sure what you mean by "use the newer version" (that seems like a very recent nightly). When you use rustup links (like
|
@ehuss: I was able to reproduce the issue with that nightly ( |
There are two issues here, neither of which are particularly easy to fix.
|
@LoganDark an you share more details about what you are doing? It might help to file a new issue. There are some known situations where Cargo buffers the output from rustc (such as the initial |
Problem
When cargo invokes
rustc
orrustdoc
(viacargo doc
orcargo build
, the child process's entire stdout is kept in memory. This can lead to the system's memory being completely exhausted ifrustc
orrustdoc
produce a lot of output (e.g. whenRUST_LOG
is set).Steps
yes.sh
containing the stringyes
(If theyes
program is unavailable, replace it with a script that endlessly writes to stdout)chmod +x ./yes.sh
RUSTC=./yes.sh cargo build
in any crate directory.Possible Solution(s)
cargo should clear each line of a child command's stdout from memory once it has been printed, since it won't be needed again.
Notes
Output of
cargo version
:cargo 1.29.0 (524a578d7 2018-08-05)
Tested on Arch Linux - this should be reproducible on any Linux-based system.
The text was updated successfully, but these errors were encountered: