Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMake the rule tree actually threadsafe #26227
Conversation
highfive
commented
Apr 20, 2020
|
Heads up! This PR modifies the following files:
|
highfive
commented
Apr 20, 2020
|
r? @emilio |
|
@bors-servo try |
Make the rule tree actually threadsafe RuleTree::gc is now a safe method that any thread can call at any time, and StrongRuleNode values can all be dropped whenever their owner want to, on any thread.
|
|
9f04b13
to
0b480a9
|
I think it would indeed make more sense to never decrement |
|
This looks good to me, thanks! I think the atomic fences could be a bit more limited, and just be loads. Other than that and a minor nit this looks good. |
| ) { | ||
| Ok(_) => { | ||
| // Increment the free count by one. | ||
| root.free_count.fetch_add(1, Ordering::Relaxed); |
This comment has been minimized.
This comment has been minimized.
emilio
Apr 20, 2020
Member
We should probably rename .free_count to .estimated_free_count or .approximate_free_count something, as it can't really be relied on for other than heuristics.
This comment has been minimized.
This comment has been minimized.
emilio
Apr 20, 2020
Member
Ah, actually you made it so it's not resetted to zero but decremented, so this is alright. Thanks!
This comment has been minimized.
This comment has been minimized.
nox
Apr 20, 2020
Author
Member
I changed it to approximate_free_count and I made swap_free_list_and_gc just swap it to 0, because what I did initially could make it underflow.
This comment has been minimized.
This comment has been minimized.
emilio
Apr 20, 2020
Member
Yeah, you're right. For posterity the bad case is: you insert into the free-list successfully, and another thread steals it and completes a gc before you get a chance to increment the count. Then the other thread would decrement the count before you get the chance to increment it, potentially underflowing.
RuleTree::gc is now a safe method that any thread can call at any time, and StrongRuleNode values can all be dropped whenever their owner want to, on any thread.
|
@bors-servo r=me |
|
err, @bors-servo r+ |
|
|
|
|
Cherry-picked from servo/servo#26227
RuleTree::gc is now a safe method that any thread can call at any time, and StrongRuleNode values can all be dropped whenever their owner want to, on any thread. Cherry-picked from servo/servo#26227
Cherry-picked from servo/servo#26227
RuleTree::gc is now a safe method that any thread can call at any time, and StrongRuleNode values can all be dropped whenever their owner want to, on any thread. Cherry-picked from servo/servo#26227
Cherry-picked from servo/servo#26227 UltraBlame original commit: 5a8370c76868c513d36a2e981b7bd90781785748
RuleTree::gc is now a safe method that any thread can call at any time, and StrongRuleNode values can all be dropped whenever their owner want to, on any thread. Cherry-picked from servo/servo#26227 UltraBlame original commit: 08a6488edafb6a74e2282ed815e7caf20a85a327
Cherry-picked from servo/servo#26227 UltraBlame original commit: 5a8370c76868c513d36a2e981b7bd90781785748
RuleTree::gc is now a safe method that any thread can call at any time, and StrongRuleNode values can all be dropped whenever their owner want to, on any thread. Cherry-picked from servo/servo#26227 UltraBlame original commit: 08a6488edafb6a74e2282ed815e7caf20a85a327
Cherry-picked from servo/servo#26227 UltraBlame original commit: 5a8370c76868c513d36a2e981b7bd90781785748
RuleTree::gc is now a safe method that any thread can call at any time, and StrongRuleNode values can all be dropped whenever their owner want to, on any thread. Cherry-picked from servo/servo#26227 UltraBlame original commit: 08a6488edafb6a74e2282ed815e7caf20a85a327
nox commentedApr 20, 2020
RuleTree::gc is now a safe method that any thread can call
at any time, and StrongRuleNode values can all be dropped
whenever their owner want to, on any thread.