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

Consider making ty::t "fatter" #2476

Closed
pcwalton opened this issue Jun 1, 2012 · 7 comments
Closed

Consider making ty::t "fatter" #2476

pcwalton opened this issue Jun 1, 2012 · 7 comments
Labels
A-type-system Area: Type system I-compiletime Issue: Problems and improvements with respect to compile times.

Comments

@pcwalton
Copy link
Contributor

pcwalton commented Jun 1, 2012

We could possibly save some time over our structural hashing and equality code if we revamped ty::t to become a packed u64 value in something approaching this form:

  • nil, bot, bool, ints, uints, floats, str, self, type, opaque box become constant values
  • estr, box, uniq, vec, ptr, rptr become (type tag: u8, mutability flags: u8, vstore/region ID: u16, enclosed type: u32)
  • enum, iface, class, res become (type tag: u8, crate ID: u8, substs ID: u16, node ID: u32)
  • tup becomes (type tag: u8, tup ID: u32)
  • rec becomes (type tag: u8, fieldset ID: u16, tup ID: u32)
  • fn becomes (type tag: u8, purity/proto/retstyle flags: u8, constrs ID: u16, signature ID: u32)
  • param becomes (type tag: u8, crate ID: u8, parameter ID: u16, node ID: u32)
  • var becomes (type tag: u8, vid: u32)
  • constr becomes (type tag: u8, constrs ID: u16)
  • opaque closure ptr becomes (type tag: u8, closure kind: u8)

We need several side tables:

  • A hash table of regions found in the program.
  • A table of linearized substs. The table contains subsituted types; at each node is a hash table (or an association list) of self_r and self_ty to ID.
  • A fieldset table.
  • A table of vstores and regions.
  • A table of linearized tuples.
  • A table of linearized function types. The return value comes first, followed by the arguments.
  • A table of constraints. Doesn't need to be fast; we rarely if ever use constraints.

By "linearized" I mean that the type in question is converted into a list and concatenated into one large string of types encoded in this way. So, for example, a list of 4 types would be 16 bytes long (but note that there are some complications with function parameter modes). This byte string forms the key in the table; thus there is never any need to traverse pointers when doing comparisons for equality, as we simply compare byte strings.

This is very rough, but I think it might speed things up.

@catamorphism
Copy link
Contributor

Nominating for "maturity #4 - well-covered".

@graydon
Copy link
Contributor

graydon commented Apr 25, 2013

possible perf win, not blocking ability-to-measure-quality.

@catamorphism
Copy link
Contributor

Bug triage. Not a release blocker.

@steveklabnik
Copy link
Member

triage: unsure what the situation is today compared to then.

@arielb1
Copy link
Contributor

arielb1 commented Jun 21, 2015

TypeVariants is 4 words ATM (= rustc 1.2.0).

@brson
Copy link
Contributor

brson commented Aug 17, 2016

This is so ancient I imagine it has nothing to do with today's rustc.

@brson brson closed this as completed Aug 17, 2016
@jonas-schievink
Copy link
Contributor

From a quick look, TypeVariants still exists and is still 4 words large (1 reference, a fat pointer (3 pointers in total) and a DefId which is 64 bits)

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
clarifying comments for target-dir handling

I thought we could simplify this logic, but alas, `cargo metadata --target-dir` is not a thing (even though the effective target-dir *does* affect the metadata).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system I-compiletime Issue: Problems and improvements with respect to compile times.
Projects
None yet
Development

No branches or pull requests

7 participants