taskflow icon indicating copy to clipboard operation
taskflow copied to clipboard

Add ability to set max steals and max yields

Open mpowelson opened this issue 3 years ago • 0 comments

When profiling our application that uses Taskflow, we noticed that std::this_thread::yield(); was causing a lot of cpu spin time. After discussing with @tsung-wei-huang, it sounds like the main problem was that our system uses multiple executors in order to keep resources independent for different types of tasks. He suggested that we try to reduce the number of executors and also that we adjust the max steals and max yields. After testing reducing the max yields and max steals (first 2 commits), this didn't seem to have much of an impact on spin time. As a result, I added an optional sleep after max yields is reached (3rd commit). This does reduce the spin time.

This PR adds the ability to set the max steals, max yields, and the sleep duration after those are reached. The defaults should work the same as before if you were using all default arguments for the executor. If you were passing in the number of threads (N), simply pass in ((N + 1) << 1) for max steals to maintain the same behavior.

mpowelson avatar Jun 17 '22 17:06 mpowelson