From 4d058f329b0eb742adc81040a12c9cae85357c3a Mon Sep 17 00:00:00 2001 From: Jeremy Ong Date: Wed, 4 Aug 2021 03:23:16 -0600 Subject: [PATCH] Use exponential backoff during job submission when ring buffers are full Signed-off-by: Jeremy Ong --- Code/Framework/AzCore/AzCore/Jobs/JobExecutor.cpp | 9 +++++---- Code/Framework/AzCore/Tests/JobGraphTests.cpp | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Jobs/JobExecutor.cpp b/Code/Framework/AzCore/AzCore/Jobs/JobExecutor.cpp index aa7f696942..83823515c1 100644 --- a/Code/Framework/AzCore/AzCore/Jobs/JobExecutor.cpp +++ b/Code/Framework/AzCore/AzCore/Jobs/JobExecutor.cpp @@ -9,13 +9,14 @@ #include #include -#include #include #include -#include +#include #include #include +#include #include +#include #include @@ -124,6 +125,7 @@ namespace AZ uint8_t priority = job->GetPriorityNumber(); QueueStatus& status = m_status[priority]; + AZStd::exponential_backoff backoff; while (true) { uint16_t reserve = status.reserve.load(); @@ -153,8 +155,7 @@ namespace AZ } else { - // TODO need exponential backup here - AZStd::this_thread::sleep_for(AZStd::chrono::microseconds{ 100 }); + backoff.wait(); } } } diff --git a/Code/Framework/AzCore/Tests/JobGraphTests.cpp b/Code/Framework/AzCore/Tests/JobGraphTests.cpp index b080e5b679..469773f471 100644 --- a/Code/Framework/AzCore/Tests/JobGraphTests.cpp +++ b/Code/Framework/AzCore/Tests/JobGraphTests.cpp @@ -565,7 +565,6 @@ namespace Benchmark graph->SubmitOnExecutor(*executor, &ev); ev.Wait(); } - executor->Drain(); } BENCHMARK_F(JobGraphBenchmarkFixture, FourToOneJoin)(benchmark::State& state) @@ -596,7 +595,6 @@ namespace Benchmark graph->SubmitOnExecutor(*executor, &ev); ev.Wait(); } - executor->Drain(); } } // namespace Benchmark #endif