[FuzzingEventEngine] add time padding to avoid busy loops

pull/35456/head
Mark D. Roth 1 year ago
parent 9e702debfb
commit 0956f3d6e1
  1. 34
      test/core/end2end/fuzzers/api_fuzzer_corpus/testcase-4861974604218368
  2. 15
      test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.cc

File diff suppressed because one or more lines are too long

@ -543,11 +543,18 @@ EventEngine::TaskHandle FuzzingEventEngine::RunAfterLocked(
const intptr_t id = next_task_id_; const intptr_t id = next_task_id_;
++next_task_id_; ++next_task_id_;
Duration delay_taken = Duration::zero(); Duration delay_taken = Duration::zero();
if (run_type != RunType::kExact && !task_delays_.empty()) { if (run_type != RunType::kExact) {
delay_taken = grpc_core::Clamp(task_delays_.front(), Duration::zero(), if (!task_delays_.empty()) {
max_delay_[static_cast<int>(run_type)]); delay_taken = grpc_core::Clamp(task_delays_.front(), Duration::zero(),
max_delay_[static_cast<int>(run_type)]);
task_delays_.pop();
} else if (when == Duration::zero()) {
// For zero-duration events, if there is no more delay input from
// the test case, we default to a small non-zero value to avoid
// busy loops that prevent us from making forward progress.
delay_taken = std::chrono::microseconds(1);
}
when += delay_taken; when += delay_taken;
task_delays_.pop();
} }
auto task = std::make_shared<Task>(id, std::move(closure)); auto task = std::make_shared<Task>(id, std::move(closure));
tasks_by_id_.emplace(id, task); tasks_by_id_.emplace(id, task);

Loading…
Cancel
Save