Skip to content

Commit

Permalink
Merge pull request #1332 from msimberg/task-size-bulk-stack-overflow
Browse files Browse the repository at this point in the history
Avoid stack overflow in `task_size` bulk test
  • Loading branch information
msimberg authored Nov 19, 2024
2 parents ae1de3d + 1411c10 commit 5791358
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/performance/local/task_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ double do_work_bulk(
for (std::uint64_t i = 0; i < tasks_per_thread; ++i)
{
sender = std::move(sender) | ex::continues_on(sched) | ex::bulk(num_threads, work);
// To avoid stack overflow when connecting, starting, or destroying the operation state,
// eagerly start the chain of work periodically using ensure_started. The chosen frequency
// is mostly arbitrary. It's done as often as reasonably possible to make the probability of
// a stack overflow very low, but not often enough to introduce significant overhead. 100
// seems like a good compromise.
if (i % 100 == 0) { sender = ex::ensure_started(std::move(sender)); }
}

double const spawn_time_s = timer.elapsed();
Expand Down

0 comments on commit 5791358

Please sign in to comment.