Uh oh!
There was an error while loading. Please reload this page.
std: Minimize size of panicking on wasm - #49488
Conversation
alexcrichton
commented
Mar 29, 2018
r? @sfackler |
est31
commented
Mar 29, 2018
So if I previously registered a custom panic handler to print the panic message via console.error (which gives you a nice stack trace btw), this panic handler will not print anything anymore? In production you probably won't want such a handler so the default setting is probably most useful for production settings. Only asking in order to understand this PR. |
There was a problem hiding this comment.
nit: shouldn't this be an unsafe trait since the box_me_up method must return a valid box pointer?
582ebbd to
8050f5aComparealexcrichton
commented
Mar 30, 2018
No, we will still invoke panic handlers |
sfackler
commented
Mar 30, 2018
LGTM other than the fast thread local stuff that sounds like it's not needed. |
est31
commented
Mar 30, 2018
@alexcrichton yes but will it get a meaningful payload? |
8050f5a to
03a18aaComparealexcrichton
commented
Mar 30, 2018
bors
commented
Mar 30, 2018
📌 Commit 03a18aa has been approved by |
alexcrichton
commented
Mar 31, 2018
fitzgen
commented
Mar 31, 2018
cc @rust-lang/wg-wasm; just a heads up!
|
03a18aa to
033b177Comparealexcrichton
commented
Mar 31, 2018
@bors: r=sfackler |
bors
commented
Mar 31, 2018
📌 Commit 033b177 has been approved by |
bors
commented
Mar 31, 2018
⌛ Testing commit 033b17760deef5251f9151f0347ad2e7d1192f1f with merge 31927a8e74b50918ba8a2d9f73c0072912245e10... |
bors
commented
Mar 31, 2018
💔 Test failed - status-travis |
TimNN
commented
Apr 7, 2018
Your PR failed on Travis. Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
1 similar comment
TimNN
commented
Apr 7, 2018
Your PR failed on Travis. Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
|
bors
commented
Apr 7, 2018
☔ The latest upstream changes (presumably #49661) made this pull request unmergeable. Please resolve the merge conflicts. |
f886518 to
e9d6cc2Comparealexcrichton
commented
Apr 9, 2018
Ok I think I've debugged the issue of the failing test. In the meantime I did a few more size optimizations here for libstd, @sfackler mind re-reviewing and re-r+'ing? |
alexcrichton
commented
Apr 9, 2018
@bors: p=0 |
There was a problem hiding this comment.
This feels non-obvious as to why it's extracted, maybe a comment would be good?
There was a problem hiding this comment.
I think a comment would be helpful...
There was a problem hiding this comment.
Removing these seems fine, but it might be good to get some perf stats on some benchmark (though I don't have any particular ideas...).
There was a problem hiding this comment.
FWIW the comment here is out of date and no longer correct, this function hasn't survived well through the various refactorings. I'll update it.
alexcrichton
commented
Apr 10, 2018
Updated! |
e9d6cc2 to
bb9c9b2Comparebors
commented
Apr 13, 2018
☔ The latest upstream changes (presumably #49669) made this pull request unmergeable. Please resolve the merge conflicts. |
This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
Create one canonical location which panics with "capacity overflow" instead of
having many. This reduces the size of a `panic!("{}", 1)` binary on wasm from
34k to 17k.The expression `&s[..i]` in general can panic if `i` is out of bounds or not on a character boundary for a string, and this caused the codegen for `Formatter::pad` to be a bit larger than it otherwise needed to be. This commit replaces this with `s.get(..i).unwrap_or(&s)` which while having different behavior if `i` is out of bounds has a much smaller code footprint and otherwise avoids the need for `unsafe` code.
This commit removes allocation of the panic message in instances like
`panic!("foo: {}", "bar")` if we don't actually end up needing the message. We
don't need it in the case of wasm32 right now, and in general it's not needed
for panic=abort instances that use the default panic hook.
For now this commit only solves the wasm use case where with LTO the allocation
is entirely removed, but the panic=abort use case can be implemented at a later
date if needed.bb9c9b2 to
46d16b6Comparealexcrichton
commented
Apr 13, 2018
ping r? @sfackler |
sfackler
commented
Apr 16, 2018
@bors r+ |
bors
commented
Apr 16, 2018
📌 Commit 46d16b6 has been approved by |
bors
commented
Apr 16, 2018
std: Minimize size of panicking on wasm This commit applies a few code size optimizations for the wasm target to the standard library, namely around panics. We notably know that in most configurations it's impossible for us to print anything in wasm32-unknown-unknown so we can skip larger portions of panicking that are otherwise simply informative. This allows us to get quite a nice size reduction. Finally we can also tweak where the allocation happens for the `Box<Any>` that we panic with. By only allocating once unwinding starts we can reduce the size of a panicking wasm module from 44k to 350 bytes.
bors
commented
Apr 17, 2018
☀️ Test successful - status-appveyor, status-travis |
This commit applies a few code size optimizations for the wasm target to
the standard library, namely around panics. We notably know that in most
configurations it's impossible for us to print anything in
wasm32-unknown-unknown so we can skip larger portions of panicking that
are otherwise simply informative. This allows us to get quite a nice
size reduction.
Finally we can also tweak where the allocation happens for the
Box<Any>that we panic with. By only allocating once unwinding startswe can reduce the size of a panicking wasm module from 44k to 350 bytes.