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

High memory use on Rust 1.51.0 with thin LTO and debuginfo #83911

Closed
jonasmalacofilho opened this issue Apr 6, 2021 · 3 comments
Closed

High memory use on Rust 1.51.0 with thin LTO and debuginfo #83911

jonasmalacofilho opened this issue Apr 6, 2021 · 3 comments
Labels
A-LTO Area: Link-time optimization (LTO) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jonasmalacofilho
Copy link

Rust 1.50.0 is able to link the example bellow using a few GB of memory, but 1.51.0/nightly needs at least 30 GB, at which point either I or the OOM killer has to abort it.

// src/main.rs

use actix_web::{web, App, HttpServer, Responder};
use std::net::TcpListener;

async fn greet() -> impl Responder {
 "Hello, World!"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    let listener = TcpListener::bind("127.0.0.1:8080")?;

    HttpServer::new(|| App::new().route("/", web::get().to(greet)))
        .listen(listener)?
        .run()
        .await?;

    Ok(())
}
# Cargo.toml

[package]
name = "example"
version = "0.1.0"
authors = ["Jonas Malaco <[email protected]>"]
edition = "2018"

[dependencies]
actix-web = "3.3"
reqwest = "0.10"

[profile.release]
lto = "thin"
debug = true

I wasn't able to reduce it beyond this, at least for now. Removing the unused dependency to reqwest, changing the LTO setting to false or fat, disabling debuginfo, or using -Clinker-plugin-lto are, each, enough to bring back the memory consumption to manageable levels.

After being aborted by the OOM killer, this is the error message:

$ cargo build --release
   [ ... ]
   Compiling example v0.1.0 (/home/jonas/Code/issues/rust/1.51-explosive-lto)
error: could not compile `example`

Caused by:
  process didn't exit successfully: `rustc --crate-name example --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto=thin -C debuginfo=2 -C metadata=576df4506149e7e2 -C extra-filename=-576df4506149e7e2 --out-dir <pwd>/target/release/deps -L dependency=<pwd>/target/release/deps --extern actix_web=<pwd>/target/release/deps/libactix_web-e15a9d0e8b71dcac.rlib --extern reqwest=<pwd>/target/release/deps/libreqwest-953a39d56f962952.rlib -L native=<pwd>/target/release/build/brotli-sys-7accbad0b10c603b/out` (signal: 9, SIGKILL: kill)

Meta

rustc --version --verbose (stable):

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

rustc --version --verbose (nightly):

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
@jonasmalacofilho jonasmalacofilho added the C-bug Category: This is a bug. label Apr 6, 2021
@jonas-schievink jonas-schievink added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Apr 6, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 6, 2021
@jyn514 jyn514 added the I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. label Apr 6, 2021
@JohnTitor JohnTitor added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example A-LTO Area: Link-time optimization (LTO) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 6, 2021
@apiraino
Copy link
Contributor

apiraino commented Apr 6, 2021

Assigning priority as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 6, 2021
@jonasmalacofilho
Copy link
Author

jonasmalacofilho commented Apr 9, 2021

Bisected from nightly-2021-01-01 to nightly-2021-03-24:

searched nightlies: from nightly-2021-01-01 to nightly-2021-03-24
regressed nightly: nightly-2021-02-06
searched commits: from 4f4656d to 23adf9f
regressed commit: 5605b5d

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2021-01-01 --end 2021-03-24 -- build --release 

That said, this is no longer reproduceable starting1 with nightly-2021-04-02.

Bisected (non-error) from from nightly-2021-03-31 to nightly-2021-04-02:

searched nightlies: from nightly-2021-03-31 to nightly-2021-04-02
regressed nightly: nightly-2021-04-02
searched commits: from 4fdac23 to d474075
regressed commit: 803ddb8

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2021-03-31 --end 2021-04-02 --regress=non-error -- build --release 

1 I wasn't able to manually install nightly-2021-04-01 with rustup.

@pnkfelix
Copy link
Member

pnkfelix commented Dec 2, 2022

Based on previous comment, namely:

That said, this is no longer reproduceable starting1 with nightly-2021-04-02.

I'm going to close this as fixed.

@pnkfelix pnkfelix closed this as completed Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LTO Area: Link-time optimization (LTO) C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants