Skip to content

WhileThunk may block in async mode #33048

@wjr-z

Description

@wjr-z

for (int64_t loop_counter = 0; loop_counter < trip_count; ++loop_counter) {
auto body_event = body_executor_.Execute(params);
// If loop iteration has not completed yet, switch to async execution mode
// using `body_event` as a dependency and continue the loop iteration
// starting from `loop_counter + 1`.
if (ABSL_PREDICT_FALSE(!body_event.IsAvailable())) {
return ExecuteAsyncForLoop(params, std::move(body_event),
loop_counter + 1, trip_count);
}

Sometimes even if the body is fast enough to execute synchronously, it may block for a long time when the number of iterations is large enough.

Possible solutions:

  1. Use cost_model of body function(If possible) to decide whether to execute asynchronously.
  2. Use timeout timer to execute asynchronously after exceeding the threshold.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions