Use exponential backoff during job submission when ring buffers are full

Signed-off-by: Jeremy Ong <jcong@amazon.com>
This commit is contained in:
Jeremy Ong
2021-08-04 03:23:16 -06:00
parent 6ac74ad41e
commit 4d058f329b
2 changed files with 5 additions and 6 deletions
@@ -9,13 +9,14 @@
#include <AzCore/Jobs/JobExecutor.h>
#include <AzCore/Jobs/JobGraph.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/queue.h>
#include <AzCore/std/parallel/binary_semaphore.h>
#include <AzCore/std/parallel/semaphore.h>
#include <AzCore/std/parallel/exponential_backoff.h>
#include <AzCore/std/parallel/mutex.h>
#include <AzCore/std/parallel/scoped_lock.h>
#include <AzCore/std/parallel/semaphore.h>
#include <AzCore/std/parallel/thread.h>
#include <AzCore/std/string/string.h>
#include <random>
@@ -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();
}
}
}
@@ -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