Skip to content

Big binary size #31

@oblique

Description

@oblique

I have this code:

fn main() {
    eui48::MacAddress::parse_str("00:11:22:33:44:55").unwrap();
}

When I compile with eui48's master branch and release profile, I get a binary of 1.4mb:

oblique@dystopia /~tmp/eui48-example
% cargo build --release
   Compiling memchr v2.4.1
   Compiling regex-syntax v0.6.25
   Compiling rustc-serialize v0.3.24
   Compiling aho-corasick v0.7.18
   Compiling regex v1.5.4
   Compiling eui48 v1.1.0 (/home/oblique/git/eui48)
   Compiling eui48-example v0.1.0 (/tmp/eui48-example)
    Finished release [optimized] target(s) in 17.78s

oblique@dystopia /tmp/eui48-example
% strip target/release/eui48-example

oblique@dystopia /tmp/eui48-example
% du -h target/release/eui48-example
1.4M	target/release/eui48-example

I noticed that you do not use any unicode features of regex, so I changed regex dependency of eui48's Cargo.toml to:

regex = { version = "1.3.9", default-features = false, features=["std"], optional = false }

and then I got a binary of 604kb:

oblique@dystopia /tmp/eui48-example
% cargo build --release
   Compiling regex-syntax v0.6.25
   Compiling regex v1.5.4
   Compiling eui48 v1.1.0 (/home/oblique/git/eui48)
   Compiling eui48-example v0.1.0 (/tmp/eui48-example)
    Finished release [optimized] target(s) in 8.42s

oblique@dystopia /tmp/eui48-example
% strip target/release/eui48-example

oblique@dystopia /tmp/eui48-example
% du -h target/release/eui48-example
604K	target/release/eui48-example

I decided to write the parsing manually and I got a binary of 264kb:

oblique@dystopia /tmp/eui48-example
% cargo build --release
   Compiling eui48 v1.1.0 (/home/oblique/git/eui48)
   Compiling eui48-example v0.1.0 (/tmp/eui48-example)
    Finished release [optimized] target(s) in 0.55s

oblique@dystopia /tmp/eui48-example
% strip target/release/eui48-example

oblique@dystopia /tmp/eui48-example
% du -h target/release/eui48-example
264K	target/release/eui48-example

Also in the latest case, compilation time is under a second.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions