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

store ADT information in an AdtDef structure in a unified way #27551

Merged
merged 14 commits into from
Aug 7, 2015

Conversation

arielb1
Copy link
Contributor

@arielb1 arielb1 commented Aug 5, 2015

This ended up being a bigger refactoring than I thought, as I also cleaned a few ugly points in rustc. There are still a few areas that need improvements.

Performance numbers:

Before:
572.70user 5.52system 7:33.21elapsed 127%CPU (0avgtext+0avgdata 1173368maxresident)k
llvm-time: 385.858

After:
545.27user 5.49system 7:10.22elapsed 128%CPU (0avgtext+0avgdata 1145348maxresident)k
llvm-time: 387.119

A good 5% perf improvement. Note that after this patch >70% of the time is spent in LLVM - Amdahl's law is in full effect.

Passes make check locally.

r? @nikomatsakis

@@ -170,7 +170,6 @@ RUST_LIB_FLAGS_ST3 += -C prefer-dynamic

# Landing pads require a lot of codegen. We can get through bootstrapping faster
# by not emitting them.
RUSTFLAGS_STAGE0 += -Z no-landing-pads
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this slipped in by accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 6, 2015

passes check locally

Perf numbers:

Before this patchset:
572.70user 5.52system 7:33.21elapsed 127%CPU (0avgtext+0avgdata 1173368maxresident)k
llvm-time: 385.858

After this patch:
557.84user 5.73system 7:22.10elapsed 127%CPU (0avgtext+0avgdata 1142848maxresident)k
llvm-time: 385.834

nice 2.5% perf improvement
@arielb1 arielb1 changed the title [WIP] store ADT information in an ADTDef structure in a unified way store ADT information in an ADTDef structure in a unified way Aug 6, 2015
@Aatch
Copy link
Contributor

Aatch commented Aug 7, 2015

Awesome, I'm glad somebody did this. The performance increase is consistent with what I saw with my version of this change. Hopefully this should also make working with ADTs easier going forward, at the very least it's much more obvious.

@nikomatsakis
Copy link
Contributor

@arielb1

I copied somewhere that did .0 (you can't believe how many places do this). I match on the binder in several places - maybe I'll add a tuple_ctor_to_type function.

Oh, I can believe it, since I wrote them, but I've been migrating code to the following conventions:

  1. Either use a proper function (like no_late_bound_regions) or,
  2. If you call skip_binder, add a comment explaining why it makes sense in this particular case.

@nikomatsakis
Copy link
Contributor

@arielb1

Having AdtDef<'tcx> be &'tcx AdtDef<'tcx,'tcx> is certainly nice. AdtDef_ is used basically nowhere (once in the tcx, once in decoder, once in collect), I'm not sure it should be behind a type alias. Also, this isn't really Mut - you can still fulfill an AdtDef<'tcx> with a Ty<'static>.

While technically true, that's not particularly interesting, is it? The intention of these types is as I wrote them, no? I'm fine if you want to note that caveat in a comment, but I still favor names that lay clear the intent of "read-only" vs "mutable", as this is a subtle trick.

@nikomatsakis
Copy link
Contributor

@arielb1

dropck was somewhat an hotspot on my profile.

How is this relevant? I'm talking about what module the code is in, not what it does.

@nikomatsakis
Copy link
Contributor

@Aatch

that's for the entire patchset up to this point (I wanted to separate it from Ty::is_simd).

ah, ok, sounds good.

@nikomatsakis
Copy link
Contributor

cc @rust-lang/compiler <-- this PR is worth having more eyes on, incidentally

@nikomatsakis
Copy link
Contributor

OK, I've finished reading through the PR. I am happy with it, this is nice work.

r+ modulo:

  • rename AdtDef_ to AdtDefData or AdtDefStruct or something similar with a word, not an underscore
  • readable type aliases for the (mostly) "read-only" &'tcx AdtDefData<'tcx,'static> and the mutable &'tcx AdtDefData<'tcx,'tcx>. Personally, I think it's worth giving both of them an alias because it makes the pattern clearer, even if the latter gets little use.
  • remove or at minimum document calls to skip_binder
  • explain where the T: Copy bound comes from (lets us use Cell; since we store &T it's fine; could be lifted in the future but would require more unsafe code). I was thinking that it mattered for concurrency but of course I was being silly: the whole POINT of an ivar is that it's write-once, and hence you can clone the contents without fear of them being overwritten, after all.

@nikomatsakis
Copy link
Contributor

ps, if you prefer, perhaps the name AdtDefTcx or something would be a compromise vs AdtDefMut ("fulfillable with a Ty<'tcx>")

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 7, 2015

addressed

@arielb1 arielb1 changed the title store ADT information in an ADTDef structure in a unified way store ADT information in an AdtDef structure in a unified way Aug 7, 2015
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 7, 2015

📌 Commit eedb1cc has been approved by nikomatsakis

bors added a commit that referenced this pull request Aug 7, 2015
This ended up being a bigger refactoring than I thought, as I also cleaned a few ugly points in rustc. There are still a few areas that need improvements.

Performance numbers:
```
Before:
572.70user 5.52system 7:33.21elapsed 127%CPU (0avgtext+0avgdata 1173368maxresident)k
llvm-time: 385.858

After:
545.27user 5.49system 7:10.22elapsed 128%CPU (0avgtext+0avgdata 1145348maxresident)k
llvm-time: 387.119
```

A good 5% perf improvement. Note that after this patch >70% of the time is spent in LLVM - Amdahl's law is in full effect.

Passes make check locally.

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Aug 7, 2015

⌛ Testing commit eedb1cc with merge ab77c1d...

@bors bors merged commit eedb1cc into rust-lang:master Aug 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants