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

Remove fast_idle and delay_exit scheduler modes and related scheduling loop checks #664

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void init_resource_partitioner_handler(
init.affinity_data_, thread_queue_init, "shared-priority-scheduler");
std::unique_ptr<high_priority_sched> scheduler(new high_priority_sched(scheduler_init));

init.mode_ = scheduler_mode(scheduler_mode::delay_exit);
init.mode_ = scheduler_mode();

std::unique_ptr<pika::threads::detail::thread_pool_base> pool(
new pika::threads::detail::scheduled_thread_pool<high_priority_sched>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ int pika_main(variables_map& vm)
scheduler_mode::steal_high_priority_first);
sched->remove_scheduler_mode(scheduler_mode::assign_work_thread_parent |
scheduler_mode::steal_after_local | scheduler_mode::reduce_thread_priority |
scheduler_mode::delay_exit | scheduler_mode::fast_idle_mode |
scheduler_mode::enable_elasticity);
}

Expand Down
3 changes: 1 addition & 2 deletions libs/pika/schedulers/tests/unit/schedule_last.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ void test_scheduler(int argc, char* argv[])
std::unique_ptr<Scheduler> scheduler(new Scheduler(init));

thread_pool_init.mode_ = pika::threads::scheduler_mode(
pika::threads::scheduler_mode::reduce_thread_priority |
pika::threads::scheduler_mode::delay_exit);
pika::threads::scheduler_mode::reduce_thread_priority);

std::unique_ptr<pika::threads::detail::thread_pool_base> pool(
new pika::threads::detail::scheduled_thread_pool<Scheduler>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,10 @@ namespace pika::threads::detail {
bool enable_stealing = scheduler.SchedulingPolicy::has_scheduler_mode(
::pika::threads::scheduler_mode::enable_stealing);

// stealing staged threads is enabled if:
// - fast idle mode is on: same as normal stealing
// - fast idle mode off: only after normal stealing has failed for
// a while
bool enable_stealing_staged = enable_stealing;
if (!scheduler.SchedulingPolicy::has_scheduler_mode(scheduler_mode::fast_idle_mode))
{
enable_stealing_staged =
enable_stealing_staged && idle_loop_count > params.max_idle_loop_count_ / 2;
}
// stealing staged threads is enabled only after normal stealing has
// failed for a while
bool enable_stealing_staged =
enable_stealing && idle_loop_count > params.max_idle_loop_count_ / 2;

if (PIKA_LIKELY(thrd ||
scheduler.SchedulingPolicy::get_next_thread(
Expand Down Expand Up @@ -679,30 +673,12 @@ namespace pika::threads::detail {

if (can_exit)
{
if (!scheduler.SchedulingPolicy::has_scheduler_mode(
scheduler_mode::delay_exit))
{
this_state.store(runtime_state::stopped);
break;
}
else
{
// Otherwise, keep idling for some time
if (!may_exit)
idle_loop_count = 0;
may_exit = true;
}
if (!may_exit)
idle_loop_count = 0;
may_exit = true;
}
}
}
else if (!may_exit && added == 0 &&
(scheduler.SchedulingPolicy::has_scheduler_mode(
scheduler_mode::fast_idle_mode)))
{
// speed up idle suspend if no work was stolen
idle_loop_count += params.max_idle_loop_count_ / 1024;
added = std::size_t(-1);
}

// call back into invoking context
if (!params.inner_.empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,37 @@ namespace pika::threads {
/// The kernel priority of the os-thread driving the scheduler will be
/// reduced below normal.
reduce_thread_priority = 0x001,
/// The scheduler will wait for some unspecified amount of time before
/// exiting the scheduling loop while being terminated to make sure no
/// other work is being scheduled during processing the shutdown
/// request.
delay_exit = 0x002,
/// Some schedulers have the capability to act as 'embedded'
/// schedulers. In this case it needs to periodically invoke a provided
/// callback into the outer scheduler more frequently than normal. This
/// option enables this behavior.
fast_idle_mode = 0x004,
/// This option allows for the scheduler to dynamically increase and
/// reduce the number of processing units it runs on. Setting this value
/// not succeed for schedulers that do not support this functionality.
enable_elasticity = 0x008,
enable_elasticity = 0x002,
/// This option allows schedulers that support work thread/stealing to
/// enable/disable it
enable_stealing = 0x010,
enable_stealing = 0x004,
/// This option allows schedulersthat support it to disallow stealing
/// between numa domains
enable_stealing_numa = 0x020,
enable_stealing_numa = 0x008,
/// This option tells schedulersthat support it to add tasks round
/// robin to queues on each core
assign_work_round_robin = 0x040,
assign_work_round_robin = 0x010,
/// This option tells schedulers that support it to add tasks round to
/// the same core/queue that the parent task is running on
assign_work_thread_parent = 0x080,
assign_work_thread_parent = 0x020,
/// This option tells schedulers that support it to always (try to)
/// steal high priority tasks from other queues before finishing their
/// own lower priority tasks
steal_high_priority_first = 0x100,
steal_high_priority_first = 0x040,
/// This option tells schedulers that support it to steal tasks only
/// when their local queues are empty
steal_after_local = 0x200,
steal_after_local = 0x080,
/// This option allows for certain schedulers to explicitly disable
/// exponential idle-back off
enable_idle_backoff = 0x0400,
enable_idle_backoff = 0x100,

// clang-format off
/// This option represents the default mode.
default_mode =
reduce_thread_priority |
delay_exit |
enable_stealing |
enable_stealing_numa |
assign_work_round_robin |
Expand All @@ -70,8 +59,6 @@ namespace pika::threads {
/// This enables all available options.
all_flags =
reduce_thread_priority |
delay_exit |
fast_idle_mode |
enable_elasticity |
enable_stealing |
enable_stealing_numa |
Expand Down