Skip to content

Using hpx::thread::sleep_for(1s) results in CPU utilization reaching 80% #6470

Answered by Pansysk75
phil-skillwon asked this question in Q&A
Discussion options

You must be logged in to vote

HPX, on its default configuration, spawns one OS thread for each core in your machine as soon as the runtime is initialized. These worker threads are constantly checking for available work (literally on a while loop, see here).
That explains the high utilization. The worker threads will eventually automatically suspend when there is no work. This can be controlled using the hpx.max_idle_backoff_time configuration value.

On the hpx::thread::sleep_for(), this will only suspend the current "HPX-thread", which is more like a user-space task. If you are interested in pausing the HPX runtime, this is described here.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@phil-skillwon
Comment options

Answer selected by hkaiser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants