-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
incr.comp.: Update fingerprint-based auto tests for red/green tracking. #44924
Comments
Review comments:
Final comment: if I clone the compiler and build, do these currently run? |
Taking up let_expressions test |
Thanks @gaurikholkar! |
I did the enum_defs.rs last time, so I can take that one to begin with. |
I just changed it to
NodeId and DefId are both predictable in the sense that we will generate the same values for them when compiling exactly the same code base twice. But there is no guarantee for them that the same item (e.g. struct definition or functions, etc) will be assigned the same NodeId and/or DefId in two sessions with code changes in between. For that we have the DefPath (which derived from the actual path of an item, like in
Well, maybe we actually should test even some more combinations. And we certainly want to cover examples for common kinds of modifications in the end-to-end tests, yes. And any problem that we find through our real-world tests and bug reports should also be turned into an appropriate regression test. |
Thanks, @eulerdisk! |
Yes, running |
@michaelwoerister thanks! |
@michaelwoerister left a comment in the gitter chat group. Thanks |
@michaelwoerister I'll start off with |
@michaelwoerister I'll take |
#45104 is the implemenation of |
@michaelwoerister as part of #45104 I'll take:
Edit: nevermind about closure_expressions.rs I'm not going to leave a lot for anybody else I don't forsee this taking too long with the new infrastructure. I think I can actually pretty much auto-write the tests with a sed expression and then the compiler will tell me what to exclude (which I will manually verify as making sense and ask you a bunch of stupid questions I'm sure 😉) Edit: @michaelwoerister is taking trait_defs + trait_impls since I was blocked by an ICE on them. |
@vitiral Go for it |
I'll take up |
Update let-expressions.rs with DepNode labels As a part of rust-lang#44924, the PR has tests verified for the following dependency nodes for **let-expressions** ``` - MirValidated - MirOptimized - TypeCheckTables - TypeOfItem - GenericsOfItem - PredicatesOfItem - FnSignature ``` As we are more concerned with the function body, the following fingerprints do not change over compilation sessions. ```- TypeOfItem - GenericsOfItem - PredicatesOfItem - FnSignature ``` r? @nikomatsakis cc @michaelwoerister P.S. Will add more tests as and when possible :)
@vitiral I was waiting for your work on |
@eulerdisk I actually really wanted to do enum_defs, so I'll take it! |
@eulerdisk done. I'm going to be on haitus for a bit after this gets merged, so you can pick up my slack 😄 |
@michaelwoerister with #45104 merged, the tutorial in this issue should probably be updated! |
@vitiral Yes, that's a good idea. Will do so soon. |
@vitiral Updated. |
@michaelwoerister as a first step I'll take:
Some of these tests are encountering missing fingerprints (
|
I'm hacking on |
update match-expressions.rs with DepNode labels As a part of rust-lang#44924, I have updated the match-expressions.rs. The PR has tests verified for the following dependency nodes for let-expressions - MirValidated - MirOptimized - TypeCheckTables - TypeOfItem - GenericsOfItem - PredicatesOfItem - FnSignature cc @michaelwoerister r? @nikomatsakis
…rs-test-to-use-incr-except, r=michaelwoerister incr: Make `unary_and_binary_exprs.rs` use `except`-style incremental checking Part of rust-lang#44924 r? @michaelwoerister
incr: Update hash tests to use `except`-style checking Part of rust-lang#44924 r? @michaelwoerister
update match-expressions.rs with DepNode labels As a part of rust-lang#44924, I have updated the match-expressions.rs. The PR has tests verified for the following dependency nodes for let-expressions - MirValidated - MirOptimized - TypeCheckTables - TypeOfItem - GenericsOfItem - PredicatesOfItem - FnSignature cc @michaelwoerister r? @nikomatsakis
…rs-test-to-use-incr-except, r=michaelwoerister incr: Make `unary_and_binary_exprs.rs` use `except`-style incremental checking Part of rust-lang#44924 r? @michaelwoerister
incr: Update hash tests to use `except`-style checking Part of rust-lang#44924 r? @michaelwoerister
…rister update let-expressions hash test to use `except` A part of rust-lang#44924, this PR updated let-expressions test using `except`. cc @michaelwoerister r? @nikomatsakis
@michaelwoerister hopefully it isn't overly greedy of me but since there hasn't been any updates for a bit, I had an urge to finish off the checklist. see #46523 |
With @CrockAgile's final push we have now updated all tests. Thank you everyone! |
…michaelwoerister Update fingerprint tests macros Part of #44924 r? @michaelwoerister
@michaelwoerister it looks like trait-impls is still outstanding with the bug I hit. I forgot to mention, but I took a stab at it a month ago with your "simple fix" and was not successful (still hitting ICE). You might want to look into it further? |
The incr. comp. system computes fingerprints (hashes) of various things and then uses these fingerprints to check if something has changed in comparison to the previous compilation session. The test cases in src/test/incremental/hashes test, at a fine-grained level, that various changes in the source code lead to changed fingerprints of various intermediate results.
Before red/green change tracking (implemented in #44901) the compiler only computed fingerprints for the inputs of a program (i.e. the HIR) and the things exported to crate metadata. With the new tracking system we also compute hashes for almost all intermediate results, but the test cases in
src/test/incremental/hashes
do not reflect that yet.A given item is tested by attaching a
#[rustc_clean]
attribute to them for expressing the expectation that the item's fingerprint has not changed, or by attaching a#[rustc_dirty]
attribute if the fingerprint should have changed. These attributes have two arguments:label
determines which kind of hash we are interested in (i.e. theDepNode
), andcfg
argument says in which compilation session this assumption should be tested.So, for example, if we want to assert that the fingerprint of the optimized MIR of a given function foo has changed between the first and the second compilation session and has not changed between sessions 2 and 3, we can do so as follows:
Since #45104 we also have a more concise way of expressing these assertions. The following snippet of code tests that all relevant results are clean, except for "MirOptimized". This obviates the need to exhaustively list all
DepKind
s that should be checked. The testing framework knows which are relevant for the item the#[rustc_clean]
or#[rustc_dirty]
attribute is attached to.The
#[cfg]
attributes attached to the function specify which version gets compiled in which compilation session (see also #36674 for another description of how these tests work). The possible values for thelabel
argument are those DepNode variants that have a singleDefId
argument.At the time of writing, there are 134 kinds of dependency nodes and it would be overkill to test fingerprints for all of these. But, depending on the kind of item under test, there are a few key ones that we should verify:
Free-standing Functions and Methods
These represent executable code, so we want to test their MIR:
MirValidated
MirOptimized
Callers will depend on the signature of these items, so we better test
TypeOfItem
,GenericsOfItem
,PredicatesOfItem
, andFnSignature
.And a big part of compilation (that we eventually want to cache) is type inference information:
TypeckTables
For methods, we can also check
AssociatedItems
which is a bit misnamed and actually describes the
ty::AssociatedItem
descriptor of the method.Struct, Enum, and Union Definitions
For these we should at least test
TypeOfItem
,GenericsOfItem
, andPredicatesOfItem
.in addition to
Hir
andHirBody
. Note that changing the type of afield does not change the type of the struct or enum, but adding/removing
fields or changing a fields name or visibility does.
Struct/Enum/Unions Fields
Fields are kind of separate from their containers, as they can change independently from them. We should at least check
TypeOfItem
for these.Trait Definitions
For these we'll want to check
TraitDefOfItem
,TraitImpls
,SpecializationGraph
,ObjectSafety
,AssociatedItemDefIds
,GenericsOfItem
, andPredicatesOfItem
(Trait) Impls
For impls we'll want to check
ImplTraitRef
,AssociatedItemDefIds
, andGenericsOfItem
.Associated Items
For associated items (types, constants, and methods) we should check
TraitOfItem
,AssociatedItems
.Test Files to Update
The existing tests can be found in the
src/test/incremental/hashes
directory. A description of how the tests were setup initially can be found in issue #36674. The basic testing strategy should stay the same -- the goal here is to add the#[rustc_dirty]
/#[rustc_clean]
attributes for the labels listed above. The test suite can be executed by running./x.py test --stage 1 src/test/incremental
.If you come a across an instance where you are not sure if it should be dirty or clean, or the compiler produces a result that's different from your expectation, feel free to leave a comment below or ask on gitter or IRC.
If you want to take on updating a specific test file, leave a comment below and I'll mark it has taken.
Good luck!
:)
The text was updated successfully, but these errors were encountered: