Skip to content

Commit cb1651e

Browse files
committed
DPL: properly handle excess of offers
1 parent c324ffb commit cb1651e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Framework/Core/src/ComputingQuotaEvaluator.cxx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ void ComputingQuotaEvaluator::updateOffers(std::vector<ComputingQuotaOffer>& pen
247247
{
248248
O2_SIGNPOST_ID_GENERATE(oid, quota);
249249
O2_SIGNPOST_START(quota, oid, "updateOffers", "Starting to processe received offers");
250+
int lastValid = -1;
250251
for (size_t oi = 0; oi < mOffers.size(); oi++) {
251252
auto& storeOffer = mOffers[oi];
252253
auto& info = mInfos[oi];
@@ -256,6 +257,9 @@ void ComputingQuotaEvaluator::updateOffers(std::vector<ComputingQuotaOffer>& pen
256257
}
257258
if (storeOffer.valid == true) {
258259
O2_SIGNPOST_EVENT_EMIT(quota, oid, "updateOffers", "Skipping update of offer %zu because it's still valid", oi);
260+
// In general we want to fill an invalid offer. If we do not find any
261+
// we add to the last valid offer we found.
262+
lastValid = oi;
259263
continue;
260264
}
261265
info.received = now;
@@ -266,7 +270,20 @@ void ComputingQuotaEvaluator::updateOffers(std::vector<ComputingQuotaOffer>& pen
266270
storeOffer.valid = true;
267271
pending.pop_back();
268272
}
269-
O2_SIGNPOST_END_WITH_ERROR(quota, oid, "updateOffers", "Some of the pending offers were not treated");
273+
if (lastValid == -1) {
274+
O2_SIGNPOST_END_WITH_ERROR(quota, oid, "updateOffers", "ComputingQuotaOffer losts. This should never happen.");
275+
return;
276+
}
277+
auto& lastValidOffer = mOffers[lastValid];
278+
for (auto& stillPending : pending) {
279+
lastValidOffer.cpu += stillPending.cpu;
280+
lastValidOffer.memory += stillPending.memory;
281+
lastValidOffer.sharedMemory += stillPending.sharedMemory;
282+
lastValidOffer.timeslices += stillPending.timeslices;
283+
lastValidOffer.runtime = std::max(lastValidOffer.runtime, stillPending.runtime);
284+
}
285+
pending.clear();
286+
O2_SIGNPOST_END(quota, oid, "updateOffers", "Remaining offers cohalesced to %d", lastValid);
270287
}
271288

272289
void ComputingQuotaEvaluator::handleExpired(std::function<void(ComputingQuotaOffer const&, ComputingQuotaStats const& stats)> expirator)

0 commit comments

Comments
 (0)