Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Conversation

@cuviper
Copy link
Member

@cuviper cuviper commented Aug 28, 2019

At preset 6, xz2 uses about 173MB of memory per thread. This adds up
quickly -- e.g. over 8GB of memory on a 48-CPU machine. If you happen to
try this in a 32-bit build, you'll get LZMA_MEM_ERROR.

We can limit this to a heuristic maximum number of threads to avoid
using so much memory, like xz's 04_compress_easy_mt example.

// The number 8 is arbitrarily chosen and may be too low or
// high depending on the compression preset and the computer
// being used.

At preset 6, xz2 uses about 173MB of memory per thread. This adds up
quickly -- e.g. over 8GB of memory on a 48-CPU machine. If you happen to
try this in a 32-bit build, you'll get `LZMA_MEM_ERROR`.

We can limit this to a heuristic maximum number of threads to avoid
using so much memory, like xz's [`04_compress_easy_mt` example].

    // The number 8 is arbitrarily chosen and may be too low or
    // high depending on the compression preset and the computer
    // being used.

[`04_compress_easy_mt` example]: https://github.com/xz-mirror/xz/blob/de1f47b2b40e960b7bc3acba754f66dd19705921/doc/examples/04_compress_easy_mt.c#L71
@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@cuviper
Copy link
Member Author

cuviper commented Aug 28, 2019

This is not hypothetical -- I hit this error in a Fedora i686 build. The build machine had 2 socket Xeon E5-2670v3 (48 CPUs) with 128GB memory, but of course a 32-bit build has more limited address space. It ended with:

BUILDSTDERR: Error: Mem
BUILDSTDERR: failed to generate installer
command did not execute successfully: "/builddir/build/BUILD/rustc-beta-src/build/i686-unknown-linux-gnu/stage0-tools-bin/fabricate" "generate" "--product-name=Rust-Documentation" "--rel-manifest-dir=rustlib" "--success-message=Rust-documentation-is-installed." "--image-dir" "/builddir/build/BUILD/rustc-beta-src/build/tmp/dist/rust-docs-beta-i686-unknown-linux-gnu-image" "--work-dir" "/builddir/build/BUILD/rustc-beta-src/build/tmp/dist" "--output-dir" "/builddir/build/BUILD/rustc-beta-src/build/dist" "--package-name=rust-docs-beta-i686-unknown-linux-gnu" "--component-name=rust-docs" "--legacy-manifest-dirs=rustlib,cargo" "--bulk-dirs=share/doc/rust/html"

@alexcrichton
Copy link
Member

Oh wow, now that's gnarly!

@alexcrichton alexcrichton merged commit 9f66c14 into rust-lang:master Aug 28, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 29, 2019
…Simulacrum

Update rust-installer to limit memory use

See rust-lang/rust-installer#98 -- on a many-core machine, the xz memory for so many threads is more than a 32-bit process can handle. The xz stream is now limited to 8 threads.

r? @alexcrichton
Centril added a commit to Centril/rust that referenced this pull request Aug 29, 2019
…Simulacrum

Update rust-installer to limit memory use

See rust-lang/rust-installer#98 -- on a many-core machine, the xz memory for so many threads is more than a 32-bit process can handle. The xz stream is now limited to 8 threads.

r? @alexcrichton
Centril added a commit to Centril/rust that referenced this pull request Aug 29, 2019
…Simulacrum

Update rust-installer to limit memory use

See rust-lang/rust-installer#98 -- on a many-core machine, the xz memory for so many threads is more than a 32-bit process can handle. The xz stream is now limited to 8 threads.

r? @alexcrichton
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants