Open workingjubilee opened 1 year ago
This looks great to me.
I take it perms
aren't actually used anywhere except the test atm? I guess I'm wondering why we store all this stuff when only address
and pathname
appear to be used? Unless I'm missing something.
We need to parse up to the pathname anyways, in order to be confident the parse is correct. However, once we have done so, we can simply discard this information, yes. I experimented with doing that but the generated rlib got bigger, surprisingly, and I figured it might reduce the final built and optimized size, but that required shoving it inside the stdlib and actually building a binary to test so I deferred that.
I'm going to hold onto this PR since it almost certainly should result in a (small) final-binary diff until either @Kobzol or myself fix the CI check so graciously added, apologies for the noise.
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 512760B Updated binary size: 513184B Difference: +424B (0.08%)
That sounds unlikely!
However, more importantly: it sounds! Thanks, @Kobzol!
Did you expect a larger increase? Currently we just compile a hello world program with panic!()
with -O
. We could try other things, like -Copt-level=s
or strip
.
I expected a decrease, actually! Let me tinker with the build settings, then.
First pass: Let's try my hypothesis that discarding all the fields will decrease the built size.
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513528B Difference: +400B (0.08%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513528B Difference: +400B (0.08%)
Okay, opt-level doesn't make a difference, but 24 bytes less means I am on to something! Maybe!
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513520B Difference: +392B (0.08%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513720B Difference: +592B (0.12%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 515056B Difference: +1928B (0.38%)
well that backfired lmao.
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513208B Difference: +80B (0.02%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 514040B Difference: +912B (0.18%)
WHAT.
"zero-cost abstractions" MY ASS.
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513896B Difference: +768B (0.15%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513752B Difference: +624B (0.12%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513200B Difference: +72B (0.01%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513928B Difference: +800B (0.16%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513712B Difference: +584B (0.11%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513712B Difference: +584B (0.11%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513712B Difference: +584B (0.11%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513200B Difference: +72B (0.01%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513200B Difference: +72B (0.01%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513216B Difference: +88B (0.02%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513216B Difference: +88B (0.02%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 513208B Difference: +80B (0.02%)
Below is the size of a hello-world Rust program linked with libstd with backtrace.
Original binary size: 513128B Updated binary size: 515184B Difference: +2056B (0.40%)
Because we expect certain inputs, we don't need chars. The code also doesn't need to validate exact lengths. This reduces the generated code size slightly.
I have some more exciting experiments which I am hoping may take off more in final Rust binaries, but which increase the intermediate rlib by more, so this is the only unequivocal win.