-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment with thread_local globals for I/O dispatch #11560
Comments
Upon some more discussion, I don't think that this is the fix that we want. This would indeed allow us to cut down the size of executables, but the key point is that it only helps LTO executables. At some point, we get to the area of diminishing returns and this is breaching into that territory. The main complaint is that the default executable is large, not that LTO executables are too large. I don't think there's enough bang for our buck with this solution, it simply requires too many workarounds to get this working and I don't believe that the benefit is that great. |
Reopening, I chatted more on IRC about this, and I was convinced that it's useful to have some way to get rid of all this extra code. This would only be useful for those running LTO, but perhaps that's "good enough" for now. I don't think this is high priority, but perhaps useful to have open. |
#17325 means this is no longer relevant to the standard libraries - the dynamic I/O dispatch won't exist |
Add missing tests for configuration options I noticed that a lot of lints didn't have test(s) for their configuration. This leads to issues like rust-lang#11481 where the lint just does nothing with it. This PR adds tests for *almost*[^1] all of the lints with a configuration that didn't have a test in ui-toml. The tests that I wrote here are usually two cases: one for where it's right above or under the limit set by the config where it shouldn't lint and another one for right above where it should. changelog: none [^1]: allow-one-hash-in-raw-strings is ignored by needless_raw_string_hashes
Test that each config value exists in a test clippy.toml Inspired by rust-lang#11560, adds a test that each config option exists in some form in a `clippy.toml` in `tests/` (currently some are in `ui-toml`, some in `ui-cargo`) changelog: none
Right now the main reason that all rust binaries are a minimum of 1MB is that all of the runtime's I/O is included in all binaries. The reason that all I/O is included is that LLVM can't eliminate the top-level I/O functions. The functions are included in a vtable which is then included in the local
Task
and it's pretty much impossible from there to be able to tell whether the vtable can be shrunk.In theory we could do some optimizations at a frontend level to detect when I/O isn't used, but it'd also be nice if LLVM did this for us.
One idea I had tonight is that all I/O dispatch functions will not use a trait, but rather a set of
thread_local
globals (initialized when threads boot). From what I can tell, LLVM can eliminate a global if there are only writes to it (no reads), and in this world if you didn't use the networking I/O, you'd never read the networking I/O global, so all of that code could get eliminated.Some points about this approach
thread_local
, currently android and windows (and osx 10.6)thread_local
because there would be dozens of these I/O functionsDespite these limitations, it's an incredibly frequent question raised on IRC about why rustc can't create a binary less than 1MB in size. This optimization would only apply to LTO'd programs, but it would at least work somewhere.
It's always been nagging at the back of my mind that we can't remove this I/O code, and this is the first idea I've had to get rid of this code, but I'm not sure how it will work out. I'm saddened that there would be more TLS globals, but the payoff may be worth it!
The text was updated successfully, but these errors were encountered: