5 ms·
I have just started playing with Actix-web. Rust-Noob as well. The yellow world example compiled to a binary that was ~ 5 MB. As a general case, Actix-web pull
by reacharavindh 8y ago
I have just started playing with Actix-web. Rust-Noob as well. The yellow world example compiled to a binary that was ~ 5 MB.
As a general case, Actix-web pulls in a lot of dependencies at install, and compile time.Are all of those dependencies really necessary for a hello world scenario?
Being a Rust newbie, I thought maybe I was using the wrong tool and started to look at hyper instead..
- DC-3 8y ago> The yellow [sic] world example compiled to a binary that was ~ 5 MB. See: "Why are Rust executables so huge" https://stackoverflow.com/questions/29008127/why-are-rust-executables-so-huge https://stackoverflow.com/questions/29008127/why-are-rust-ex...
- sondr3 8y ago5MB is nothing compared to what you'd use for a similar project in node or Python or Ruby. Sure, it's not the tiniest it could be, but using tools like strip, not including debug symbols etc it gets pretty damn small. Honestly though, at that point I think size becomes entirely pointless to even mention unless you need to run it in a super constrained environment, which you're probably not when you're using the standard library :)
- reacharavindh 8y agoYes, I'm not constrained in any way to not be able to run a 5 MB binary. I was curious if that was an indication of what is to come for large projects... I guess I was tangentially pointing to complexity and abstraction there.
- empath75 8y agorust doesn't use dynamic linking, which contributes a lot to that size.
- steveklabnik 8y agoIt can, but for practical reasons, generally does not. For Rust code anyway; often anything bound via FFI is dynamically linked.
- kingosticks 8y agoWont a crate compiled with 'crate_type = "dylib"' be dynamically linked if you specify '-C prefer-dynamic' when compiling your program? https://doc.rust-lang.org/reference/linkage.html https://doc.rust-lang.org/reference/linkage.html
- skolemtotem 8y agoThis is pedantic, but rust does link dynamically, but only to libc.
- timlyo 8y agoThere's a lot that can be done to shrink a Rust binary[0]. A copy of the summary: - Compile with --release. - Before distribution, enable LTO and strip the binary. - If your program is not memory-intensive, use the system allocator (assuming nightly). - You may be able to use the optimization level s/z in the future as well. - I didn’t mention this because it doesn’t improve such a small program, but you can also try UPX and other executable compressors if you are working with a much larger application. [0]https://lifthrasiir.github.io/rustlog/why-is-a-rust-executable-large.html https://lifthrasiir.github.io/rustlog/why-is-a-rust-executab...
- steveklabnik 8y agos/z was made stable ten days ago: https://github.com/rust-lang/rust/pull/50265 https://github.com/rust-lang/rust/pull/50265 So, two releases :)
- oblio 8y ago> I have just started playing with Actix-web. Rust-Noob as well. The yellow world example compiled to a binary that was ~ 5 MB. I've only played around with Rust a bit, but IMO, as a general rule: don't judge back-end frameworks by the size of the deliveries, unless we're talking about something ridiculous (5GB). It's extremely superficial and has a very low correlation with the quality of the actual tool.