rust-lang / backtrace-rs

Backtraces in Rust
https://docs.rs/backtrace
Other
524 stars 240 forks source link

Track permissions as bytes #540

Open workingjubilee opened 1 year ago

workingjubilee commented 1 year ago

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.

ChrisDenton commented 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.

workingjubilee commented 1 year ago

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.

workingjubilee commented 1 year ago

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.

github-actions[bot] commented 1 year ago

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%)

workingjubilee commented 1 year ago

That sounds unlikely!

workingjubilee commented 1 year ago

However, more importantly: it sounds! Thanks, @Kobzol!

Kobzol commented 1 year ago

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.

workingjubilee commented 1 year ago

I expected a decrease, actually! Let me tinker with the build settings, then.

workingjubilee commented 1 year ago

First pass: Let's try my hypothesis that discarding all the fields will decrease the built size.

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

workingjubilee commented 1 year ago

Okay, opt-level doesn't make a difference, but 24 bytes less means I am on to something! Maybe!

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

workingjubilee commented 1 year ago

well that backfired lmao.

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

workingjubilee commented 1 year ago

WHAT.

workingjubilee commented 1 year ago

"zero-cost abstractions" MY ASS.

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)

github-actions[bot] commented 1 year ago

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%)