Skip to content
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

[MIR] Store MIR in crate metadata #30301

Merged
merged 6 commits into from
Dec 11, 2015

Conversation

michaelwoerister
Copy link
Member

This PR makes Mir RustcEncodable and RustcDecodable and stores it in crate metadata for inlinable items.

Some other things in here:

  • mir::visit::Visitor is extended to also visit Literals, Spans and DefIds.
  • It also adds mir::visit::MutVisitor which allows to mutate the visited Mir structure in place.
  • Some numbers on how big MIR is in metadata (total metadata size in bytes):
w/ MIR w/o MIR Rel. Size
libcore 17,695,473 14,263,377 124%
liblibc 411,440 404,382 102%
libcollections 4,537,975 3,526,933 129%
libserialize 2,574,769 2,060,798 125%
libsyntax 15,262,894 12,075,574 126%
librustc 16,984,537 13,692,168 124%

So, adding MIR to metadata makes it about 25% bigger. It could be worse, considering that it still uses the inefficient RBML encoding. Still, the question is whether we should put MIR emission behind a -Z flag.

@michaelwoerister michaelwoerister added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Dec 10, 2015
@rust-highfive
Copy link
Collaborator

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@michaelwoerister
Copy link
Member Author

r? @nikomatsakis

@michaelwoerister michaelwoerister force-pushed the mir-to-metadata2 branch 2 times, most recently from bcff7ba to 7786e1e Compare December 10, 2015 16:47
@nikomatsakis
Copy link
Contributor

cc @alexcrichton @brson -- thoughts about binary size? this would only be temporary until MIR trans lands, of course, but that could be a little while.

UPDATE: To be clear, I mean that eventually we would not have to include the HIR as well.

@nikomatsakis
Copy link
Contributor

r+ modulo the two comments -- no tests, but that's ok because this is going to be used very heavily and is already tested in mw's local branches (also, I don't believe there are any tests for metadata encoding-decoding at all, so no existing infrastructure)

@alexcrichton
Copy link
Member

There've been some nice improvements to metadata size recently so this may just get us back to where we used to be at, so in that sense it's not that much worse.

One possibility perhaps could be to only enable this on the nightly channel, but if MIR is enabled anywhere this seems ok to me as HIR is on its way out.

@arielb1
Copy link
Contributor

arielb1 commented Dec 10, 2015

So many bloat. We need to try and get it under control.

@@ -632,7 +652,7 @@ pub struct DebruijnIndex {
///
/// [1] http://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/
/// [2] http://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/
#[derive(Clone, PartialEq, Eq, Hash, Copy)]
#[derive(Clone, PartialEq, Eq, Hash, Copy, RustcEncodable, RustcDecodable)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you doing? Are we encoding non-erased regions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Region shows up in mir::repr::Rvalue so we need serialization implementations for it. At the encoding time it should always have been erased though.

@michaelwoerister
Copy link
Member Author

So many bloat. We need to try and get it under control.

At some point we definitely should, I agree.

@michaelwoerister
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Dec 10, 2015

📌 Commit 5addc31 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Dec 11, 2015

⌛ Testing commit 5addc31 with merge 7ce7139...

bors added a commit that referenced this pull request Dec 11, 2015
This PR makes `Mir` `RustcEncodable` and `RustcDecodable` and stores it in crate metadata for inlinable items.

Some other things in here:
- `mir::visit::Visitor` is extended to also visit `Literals`, `Spans` and `DefIds`.
- It also adds `mir::visit::MutVisitor` which allows to mutate the visited `Mir` structure in place.
- Some numbers on how big MIR is in metadata (total metadata size in bytes):

|                | w/ MIR     | w/o MIR     | Rel. Size |
|----------------|-----------:|------------:|:---------:|
| libcore        | 17,695,473 |  14,263,377 |  124%     |
| liblibc        | 411,440   |  404,382    | 102%      |
| libcollections |  4,537,975 |   3,526,933 |   129%    |
| libserialize   |  2,574,769 |   2,060,798 |   125%    |
| libsyntax      | 15,262,894 |  12,075,574 |  126%     |
| librustc       | 16,984,537 |  13,692,168 |  124%     |

So, adding MIR to metadata makes it about 25% bigger. It could be worse, considering that it still uses the inefficient RBML encoding. Still, the question is whether we should put MIR emission behind a `-Z` flag.
1 similar comment
@bors bors merged commit 5addc31 into rust-lang:master Dec 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants