68 auto& selected = offers[
ref];
69 auto& info = infos[
ref];
71 if (info.firstUsed == 0) {
80 stats.invalidOffers.clear();
81 stats.otherUser.clear();
82 stats.unexpiring.clear();
83 stats.selectedOffers.clear();
84 stats.expired.clear();
93 LOGP(
LOGLEVEL,
"{} offers were selected for a total of: cpu {}, memory {}, shared memory {}",
result.size(), totalOffer.cpu, totalOffer.memory, totalOffer.sharedMemory);
102 if (stats.invalidOffers.size()) {
105 if (stats.otherUser.size()) {
108 if (stats.expired.size()) {
111 if (stats.unexpiring.size() > 1) {
119 int64_t minValidity = 0;
131 if (offer.valid ==
false) {
132 stats.invalidOffers.push_back(
i);
135 if (offer.user != -1 && offer.user != task) {
136 stats.otherUser.push_back(
i);
139 if (offer.runtime < 0) {
140 stats.unexpiring.push_back(
i);
141 }
else if (offer.runtime + info.received < now) {
142 LOGP(
LOGLEVEL,
"Offer {} expired since {} milliseconds and holds {}MB",
i, now - offer.runtime - info.received, offer.sharedMemory / 1000000);
144 stats.expired.push_back(
i);
147 LOGP(
LOGLEVEL,
"Offer {} still valid for {} milliseconds, providing {}MB",
i, offer.runtime + info.received - now, offer.sharedMemory / 1000000);
148 if (minValidity == 0) {
149 minValidity = offer.runtime + info.received - now;
151 minValidity = std::min(minValidity,(int64_t)(offer.runtime + info.received - now));
154 assert(offer.sharedMemory >= 0);
155 auto tmp = accumulated;
156 tmp.
cpu += offer.cpu;
157 tmp.memory += offer.memory;
158 tmp.sharedMemory += offer.sharedMemory;
159 offer.score = selector(offer, tmp);
160 switch (offer.score) {
168 stats.selectedOffers.push_back(
i);
173 stats.selectedOffers.push_back(
i);
179 if (minValidity != 0) {
180 LOGP(
LOGLEVEL,
"Next offer to expire in {} milliseconds", minValidity);
182 LOGP(
LOGLEVEL,
"Offer should be expired by now, checking again");
184 minValidity + 100, 0);
187 return summarizeWhatHappended(enough, stats.selectedOffers, accumulated, stats);
std::function< void(int id, std::array< ComputingQuotaOffer, 16 > &, ComputingQuotaStats &, std::function< void(ComputingQuotaOffer const &, ComputingQuotaStats &stats)>)> ComputingQuotaConsumer