Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTrait system rewrite #8
Comments
aturon
added
Project
T-compiler
T-lang
labels
Jan 31, 2017
This was referenced Jan 31, 2017
This comment has been minimized.
This comment has been minimized.
mrkgnao
commented
Feb 7, 2017
|
Something I noticed: @nikomatsakis' proposed "stages of typing" reminds me of how Haskell is compiled, especially in how they propose RFCs should be evaluated. The GHC section of The Architecture of Open Source Applications mentions something similar with respect to the GHC Core intermediate language that might be interesting to look at. |
aturon
referenced this issue
Mar 6, 2017
Merged
Generic associated types (associated type constructors) #1598
This comment has been minimized.
This comment has been minimized.
|
Note that ongoing work is happening in the Chalk repository. This is a standalone trait system/prolog engine, which we hope will double as an executable specification/test system for rustc. There are a few more major pieces to land here (e.g., specialization), and then we'll focus on porting the ideas to rustc proper. |
This comment has been minimized.
This comment has been minimized.
|
Added links to blog posts. |
This was referenced Apr 28, 2017
This was referenced May 31, 2017
Mark-Simulacrum
referenced this issue
Jun 23, 2017
Closed
ability to opt out of auto-rolling of reflexive From #42861
This comment has been minimized.
This comment has been minimized.
JoeyAcc
commented
Jun 26, 2017
•
|
Just out of curiosity: |
This comment has been minimized.
This comment has been minimized.
|
My understanding is that Chalk is mostly about correctness and ease of adding things in the future, but also is supposed to perform better. However, you gotta think about this in an Amdahls' law sense: figuring out what traits apply is rarely a significant part of compilation time, so even speeding it up a lot probably won't speed up compile times overall a ton. I'm not on the compiler team though so I may be wrong about any part of this. |
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik - iirc, @nikomatsakis mentioned at one point that the trait stuff is threaded through the typechecking so improvements in it may have some wall-clock improvement in compile time, though not sure what percent improvement it could reasonably give. Maybe he could speak to it? |
This comment has been minimized.
This comment has been minimized.
That's incorrect; it can be substantial. Chalk should help in part by providing a much better caching strategy. |
This comment has been minimized.
This comment has been minimized.
Kixunil
commented
Sep 13, 2017
|
Is this the correct issue to track if I'm interested in status of wiring Chalk into the compiler or is there something better? |
aturon commentedJan 31, 2017
•
edited
Point of contact
@nikomatsakis @aturon
Overview
The current trait system implementation is written in a "direct" style, where we perform search directly on impls and so on. While we've taken pains to keep this implementation clean, it's still quite complicated and ad hoc, and has a number of pitfalls:
Performance is limited by the amount of caching we can perform. Caching currently takes into account irrelevant information, meaning that cache misses are more common than they should be. Changing this in the current setup is not easy.
There are a lot of limitations around associated types and higher-ranked trait bounds, which again are hard to lift within the current setup.
There are a number of extensions we'd like to make to the trait system, but doing so would require substantial refactorings.
We're now exploring a re-write based on logic programming, where we understand traits and impls as a logic program against which we can make queries. This should allow for a much more principled implementation, better caching, and easier extension to new features (like associated type constructors).
Status
The Chalk project is a standalone trait system/prolog engine, which serves as a prototype and specification for what we want in rustc itself. It's quite far along at this point, but is still missing a few crucial pieces (like specialization).
We're also doing some refactoring in rustc, ahead of the work to port Chalk's ideas into rustc proper.
In the long run, we'd like to have the ability to run Chalk side-by-side with rustc, as an addon to the compiler's test suite.
Blog posts: