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 upNonzeroing Move Hints (take3 branch) #26173
Conversation
rust-highfive
assigned
Aatch
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
|
r? @Aatch (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
rust-highfive
assigned
nikomatsakis
and unassigned
Aatch
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Note: I am still putting this branch through its paces locally. My most recent
Not sure yet what is up with that; it could be a latent bug in my PR, or some other bad interaction. In any case, I wanted to put this up for some preliminary review; I suspect that even if we cannot land the whole PR yet, some of the earlier commits that refactor the code may be worth landing on their own. |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
(i'm sure people are curious about performance results too. I can work on posting some numbers once I regather them, but the expectation based on my earlier measurements is that this yields somewhere between a 2% and 5% improvement in compilation time. It is not 100% clear where the improvement is coming from; that is, I had thought we would be able to clearly associate the improvement with one factor like "LLVM is spending less time trying to optimize code") |
This comment has been minimized.
This comment has been minimized.
|
(I do want to read over @eefriedman 's alternative approach to removing drop flags, at eefriedman:dynamic-drop ; but I wanted to get this up first since as I said it has some changes that may want to land regardless of what overall strategy we adopt.) |
This comment has been minimized.
This comment has been minimized.
|
cc @carllerche |
This comment has been minimized.
This comment has been minimized.
|
The There is not a 100% clear smoking gun from the debugger backtraces, however. Most of the backtraces look like this:
but there were two that looked like this:
and then there was another that looked like this:
(Its certainly possible that one of the cases that is marked as |
pnkfelix
force-pushed the
pnkfelix:fsk-trans-nzmove-take3
branch
from
4ff13a3
to
7d7dbcb
Jun 10, 2015
This comment has been minimized.
This comment has been minimized.
|
@pnkfelix did you observe an improvement in execution time as well? I cannot recall :) |
eefriedman
reviewed
Jun 10, 2015
| // FIXME (#5016): pnkfelix is not 100% sure how we are | ||
| // going handle this long-term. Maybe easiest to just | ||
| // not allow arguments that are Drop to be passed | ||
| // indirectly. |
This comment has been minimized.
This comment has been minimized.
eefriedman
Jun 10, 2015
Contributor
If the caller is trying to drop the alloca used for an indirect argument, that's a bug. They shouldn't be touched at all after a call because the callee is guaranteed to drop them. (At least, that's how I understand the current model.)
This comment has been minimized.
This comment has been minimized.
eddyb
Jun 10, 2015
Member
Yes, that is correct. The callee owns the value, they can move it, drop it, etc.
This comment has been minimized.
This comment has been minimized.
pnkfelix
Jun 10, 2015
Author
Member
Okay, I'll see if I can properly encode this and avoid the ZeroAndMaintain here in that case. (But first I want to fix the bugs i am observing with this branch as it stands...)
eefriedman
reviewed
Jun 10, 2015
|
|
||
| /// Binding a non-copy type by reference under the hood; this is | ||
| /// a codegen optimization to avoid unnecessary memory traffic. | ||
| TrByMoveRef, |
This comment has been minimized.
This comment has been minimized.
eefriedman
Jun 10, 2015
Contributor
Not sure whether it's worth separating TrByCopy and TrByMoveIntoCopy, given that they are conceptually both assignment, but separating out TrByMoveRef is definitely a good idea; I was initially very confused trying to sort out what this code was doing.
This comment has been minimized.
This comment has been minimized.
pnkfelix
Jun 10, 2015
Author
Member
Well, if we conflate TrByCopy and TrByMoveIntoCopy, then I think we end up back where we started (though perhaps with different names overall.
The only place where I think the handling of TrByCopy and TrByMoveIntoCopy differs in what kind of Lvalue I construct in insert_lllocals; everywhere else the two are collapsed.
(I personally found it nice to separate them just because I so strongly connect the word Copy with types that actually implement Copy...)
This comment has been minimized.
This comment has been minimized.
eefriedman
reviewed
Jun 10, 2015
| @@ -529,7 +640,7 @@ impl<'tcx> Datum<'tcx, Lvalue> { | |||
| }; | |||
| Datum { | |||
| val: val, | |||
| kind: Lvalue, | |||
| kind: Lvalue::new("Datum::get_element"), | |||
This comment has been minimized.
This comment has been minimized.
eefriedman
Jun 10, 2015
Contributor
Having post_store panic when it couldn't generate correct code was very helpful on my branch. Maybe less useful here, but it might still be a good idea here to associate a "cannot be moved" hint with certain lvalues, like fields of lvalues with hints, which can't be moved safely.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
This looks good to me. |
brson
added
the
relnotes
label
Jun 12, 2015
This comment has been minimized.
This comment has been minimized.
|
(note that there is still that bug I need to resolve, noted above) |
This comment has been minimized.
This comment has been minimized.
Two weeks later: After some more investigation (that was interrupted several time for long stretches), I am pretty confident that the only bugs left to resolve are poor interactions with the drop-flag sanity checking that I put in. In other words, if I cannot resolve those interactions quickly, then I will be happy to simply remove the sanity checking, and get this landed. |
pnkfelix
force-pushed the
pnkfelix:fsk-trans-nzmove-take3
branch
from
451b524
to
29ab769
Jun 30, 2015
pnkfelix
force-pushed the
pnkfelix:fsk-trans-nzmove-take3
branch
from
29ab769
to
c0e4e95
Jul 23, 2015
This comment has been minimized.
This comment has been minimized.
|
r+ modulo comments and nits. |
pnkfelix
added some commits
Jun 5, 2015
pnkfelix
added some commits
Jun 7, 2015
pnkfelix
force-pushed the
pnkfelix:fsk-trans-nzmove-take3
branch
from
c0e4e95
to
b4dd765
Jul 28, 2015
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
bors
added a commit
that referenced
this pull request
Jul 28, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
pnkfelix commentedJun 10, 2015
Add dropflag hints (stack-local booleans) for unfragmented paths in trans. Part of #5016.
Added code to maintain these hints at runtime, and to conditionalize drop-filling and calls to destructors.
In this early stage of my incremental implementation strategy, we are using hints, so we are always free to leave out a flag for a path -- then we just pass
Noneas the dropflag hint in the corresponding schedule cleanup call. But, once a path has a hint, we must at least maintain it: i.e. if the hint exists, we must ensure it is never set to "moved" if the data in question might actually have been initialized. It remains sound to conservatively set the hint to "initialized" as long as the true drop-flag embedded in the value itself is up-to-date.I hope the commit series has been broken up to be readable; most of the commits in the series should build (though I did not always check this).
Oh, I think this technically qualifies as a:
[breaking-change]
because it removes drop-filling in some cases where one could previously observe it. That should only affect
unsafecode; no safe code should be able to inspect whether the drop-fill was present or not. For an example of code that needed to change to account for this, see commit a81c24a (a unit test of themove_val_initintrinsic). I have not encountered actual code that needed to be updated to account for the change, since this should only be skipping the drop-filling on moved values, not on dropped one, and so even types that useunsafe_no_drop_flagshould be unchanged by this particular PR. (Their time will come later.)