Skip to content

Executable size impact #275

@RazrFalcon

Description

@RazrFalcon

Here is a simple demo:

#[macro_use] extern crate log;
extern crate fern;

fn main() {
    fern::Dispatch::new()
        .level(log::LevelFilter::Warn)
        .chain(std::io::stderr())
        .apply().unwrap();

    warn!("Hello, world!");
//     println!("Hello, world!");
    test();
}

fn test() {
    warn!("Hello, world!");
//     println!("Hello, world!");
}

According to the cargo-bloat, the code size with warn in the release build is 1000B and with println - 717B. Why it impacts the size so much? Maybe this is a cargo-bloat bug (yes, I'm the author)?

In the real world applications, the results are even more drastic. For example, if I remove all the logging from this module the size in the release build will be reduced from 9.1KiB to 3.1KiB. It's ridiculous.

I this is a correct behavior or am I missing something?

log v0.4.1
fern v0.5.5
cargo-bloat v0.5.0
rustc 1.26.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions