Resolver cm token - #160345
Conversation
|
Ah, one extra thing. The // self is &mut Resolver
for _ in &self.iterable_field {
self.resolution().borrow(self.cm_token());
}because the iterator is shared on the resolver field, doing |
|
@bors delegate try |
|
✌️ @LorrensP-2158466, you can now perform try builds on this pull request! You can now post |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (358e11b): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.6%, secondary -2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.1%, secondary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.553s -> 490.99s (0.09%) |
|
It's only |
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
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.
|
I wouldn't want to introduce a lot of unsafe code an copypaste of I'll review after the second benchmark run finishes and the manual ref counting commit is removed. |
|
Reminder, once the PR becomes ready for a review, use |
Understandable, I was mostly curious :). |
|
If we have methods taking a token, then panicking methods not taking a token are not necessary anymore (*). impl Resolver {
fn token1(&mut self) -> CmToken { debug_assert!(!self.assert_speculative); CmToken { ... } }
fn token2(&self) -> CmToken { assert!(!self.assert_speculative); CmToken { ... } }
}(*) Unless there are borrow checker issues like #160345 (comment), then we can have more unsafe methods taking a boolean or something. |
|
Finished benchmarking commit (5ea1493): comparison URL. Overall result: no relevant changes - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (primary 0.8%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.3%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 490.553s -> 489.78s (-0.16%) |
hmm, lets see, that would be nicer as well.
I don't think it would be more "problematic" as it is now. |
7f2cb4f to
9c15c08
Compare
|
I actually don't like this way of obtaining a token, I find it rather confusing. I thought of it as a way to circumvent the Also, this is not applicable to @rustbot ready. |
…e resolution. no more `*_with_token` functions now
9c15c08 to
65839dd
Compare
| // ``` | ||
| // | ||
| // We know that none of these `Untracked` borrows are alive after the import | ||
| // resolution phase is done (`assert_speculative = false`); so we deem this "safe". |
There was a problem hiding this comment.
I think we could shift the safety responsibility to the assert_speculative flag.
Like "you cannot change the value of assert_speculative if any RefOrMuts obtained with Resolver::cm(_mut) are alive, or any CmRefs obtained with CmRefCell::borrow are alive, or [add the full list]".
We could make setting the assert_speculative flag formally unsafe by hiding it into some private field and exposing the modification through an unsafe method.
Some of the borrow methods could actually ensure that their return values are dead statically - if they capture the resolver reference (even through phantom data), then you won't be able to change assert_speculative because changing it requires exclusive access to the resolver. (Although it may be inconvenient to work with.)
There was a problem hiding this comment.
Yeah, I like the idea of making assert_speculative an unsafe field.
Some of the borrow methods could actually ensure that their return values are dead statically - if they capture the resolver reference (even through phantom data), then you won't be able to change assert_speculative because changing it requires exclusive access to the resolver. (Although it may be inconvenient to work with.)
Ooh, a sort of guard that ensure the borrow is dropped before being allowed to change assert_speculative. I think we will see some issues with functions that use take a &mut Resolver (view types/borrows would be really handy :D).
I'll do these in separate commits, one for unsafe field and one for tying the borrow to the resolver/unsafe field. Or a another pr?
There was a problem hiding this comment.
Another PR, I'm busy this week and will be on vacation next week, so reviewing in small pieces will be more convenient.
There was a problem hiding this comment.
Okey, i'll work on top of this one.
No, not really needed. i'll just pull this change of tracked/untracked borrows in a separate pr.
I think this can be addressed by making obtaining a token from |
Yeah, agreed, something like |
View all comments
part of #158845
follow up of #160271 (first commit of this pr)
Introduces a
CmTokenobtainable only through a&mut Resolver. Which allows*_with_tokenmethods to be used inCmCellandCmRefCellmutating functions.Also changes
CmRefCell::borrowto return aCmRefbassed onresolver.assert_speculative, aborrow_with_tokenis also introduced.r? @petrochenkov