-
Notifications
You must be signed in to change notification settings - Fork 13
Only work-steal in the main loop #12
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
base: rustc
Are you sure you want to change the base?
Conversation
The regression looks regrettable, and it will probably prevent us from landing parallel rustc. I would like us to decide whether to work-stealing by querying dependencies instead of prohibiting it in inner loops. I hope we can left this change and try other implementations first. |
0481924
to
a0a8c45
Compare
By increasing the thread count we can increase the work stealing done and thus reduce the regression:
|
@cuviper Would you be up for reviewing this? |
Hello! Do you have any tips on currently triggering those bugs? |
I haven't had time to review this in depth -- but seeing how many deep areas it needs to change, along with existing patches diverging from rayon, I'm starting to think that we would be better off with a bespoke |
I am currently working on this and other parallelization issues. |
@Zoxc wouldn't that mess up with the jobserver? It raises the limit of number cores used in parallel. |
Yeah, this does seem to imply a move away from tracking Rayon. This approach doesn't match well with Rayon iterators and we may want to introduce fibers too. I'd like to see some more extensive testing to verify this solves the deadlock issues before moving further in this direction though.
Not sure what you mean here? The jobserver would still limit active threads across cores as before. |
I should have done it much earlier, but I endorse this PR. Merging it would allow to make progress on parallelizing rustc code and stabilizing parallel front-end. Doubling number of threads seem like a worth enough compromise. |
c57dfbd
to
652d859
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of tests that are now ignored. Either change them to the new behaviour or leave a comment on them why they are ignored and why their behaviour is now nonsensical. Or I guess remove them if the tests only ever tested work stealing from all threads.
@@ -99,13 +100,22 @@ where | |||
OP: Fn(BroadcastContext<'_>) -> R + Sync, | |||
R: Send, | |||
{ | |||
let current_thread = WorkerThread::current(); | |||
let current_thread_addr = current_thread as usize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use expose_provenance
instead to clearly signal intent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or use an AtomicPtr instead of an AtomicUsize for the latch. That should work, too, right?
let current_thread = WorkerThread::current().as_ref(); | ||
let current_thread = current_thread.as_ref(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preexisting, but it is very confusing that this entire function body is unsafe. Let's move to a new edition once the crate is in tree
kind of a big hammer for this problem. But I can't think of anything robust otherwise |
This PR removes work stealing from other threads, except when in the main loop. This avoids situations where we steal work we can't complete due to waiting on queries. This should fix bugs like rust-lang/rust#111521 and rust-lang/rust#115223, but it does have a negative performance impact.
Tests for 6 threads: