Skip to content
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

Add env vars for ROUNDS_UNTIL_SLEEPY and ROUNDS_UNTIL_ASLEEP #684

Closed
wants to merge 1 commit into from

Conversation

aloucks
Copy link

@aloucks aloucks commented Aug 24, 2019

Running rayon in a rather tight loop can cause very high cpu and power consumption that is not proportional to the amount of work being performed. As documented in the sleep module, this is caused by the work stealing algorithm and workers spinning in a hot loop while looking for work.

This commit adds two environment variables that serve as configuration knobs and allows the user to adjust how aggressive the workers behave.

  • RAYON_ROUNDS_UNTIL_SLEEPY
  • RAYON_ROUNDS_UNTIL_ASLEEP

Running rayon in a rather tight loop can cause very high cpu and power
consumption that is not proportional to the amount of work being performed.
As documented in the sleep module, this is caused by the work stealing
algorithm and workers spinning in a hot loop while looking for work.

This commit adds two environment variables that serve as configuration
knobs and allows the user to adjust how aggressive the workers behave.

* `RAYON_ROUNDS_UNTIL_SLEEPY`
* `RAYON_ROUNDS_UNTIL_ASLEEP`
@nikomatsakis
Copy link
Member

@aloucks have you tried this in practice and found it effective? Is the goal here to keep the threads active a bit longer before they fall asleep?

@cuviper
Copy link
Member

cuviper commented Aug 26, 2019

I suspect they want to decrease the numbers to sleep sooner and reduce idle-CPU usage. I mentioned a small trial with these values in #642 (comment).

I feel really wary of exposing these internals though.

@aloucks
Copy link
Author

aloucks commented Aug 27, 2019

I suspect they want to decrease the numbers to sleep sooner and reduce idle-CPU usage.

Yes, this exactly.

@wagnerf42
Copy link
Contributor

just to be sure I get it. a round (bounded by the 32 and 64 values) is a steal request ?
what is the duration before sleep ? I cannot really see how this could be a problem. you have a sequential loop on really tiny unbalanced parallel computations ?

@nikomatsakis
Copy link
Member

OK. I don't think we'd want to expose those details, but I do think it might be reasonable to let users supply some kind of configuration to the thread-pool when its created. Probably a more abstract one. (Of course we've long wanted to revisit our "sleep mechanism" in any case.)

@nikomatsakis
Copy link
Member

The sleeping code has been completely rewritten by now, so I think we can close this PR. @aloucks have you had a chance to try the new scheduler by the way? Hopefully it is doing a better job when it comes to CPU performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants