Closed
Description
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 <jonas@protocubo.io>"]
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
Metadata
Metadata
Assignees
Labels
Area: Link-time optimization (LTO)Category: This is a bug.Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleIssue: Problems and improvements with respect to memory usage during compilation.High priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.