Skip to content

Commit d56ac2d

Browse files
committed
do not overpopulate the cache
1 parent a51423a commit d56ac2d

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

Framework/CCDBSupport/src/AnalysisCCDBHelpers.cxx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/)
175175
}
176176
int outputRouteIndex = bindings.at(outRouteDesc);
177177
auto& spec = helper->routes[outputRouteIndex].matcher;
178+
auto concrete = DataSpecUtils::asConcreteDataMatcher(spec);
179+
Output output{concrete.origin, concrete.description, concrete.subSpec};
178180
auto builders = allbuilders | std::views::filter([&i](auto const& builder) { return builder.first == i; });
179181
unsigned int numBuilders = std::ranges::count_if(allbuilders, [&i](auto const& builder) { return builder.first == i; });
180182
arrow::Status status;
@@ -187,6 +189,8 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/)
187189
throw framework::runtime_error_f("Failed to reserve arrays: ", status.ToString().c_str());
188190
}
189191

192+
std::vector<DataAllocator::CacheId> lastIds(numBuilders, DataAllocator::CacheId{.value = -1, .handle = -1, .segment = -1});
193+
190194
for (auto ci = 0; ci < timestampColumn->num_chunks(); ++ci) {
191195
std::shared_ptr<arrow::Array> chunk = timestampColumn->chunk(ci);
192196
auto const* timestamps = chunk->data()->GetValuesSafe<size_t>(1);
@@ -218,6 +222,11 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/)
218222
int bi = 0;
219223
for (auto& builder : builders) {
220224
auto& response = responses[bi];
225+
auto& lastId = lastIds[bi];
226+
if (response.id.value != lastId.value) {
227+
lastId.value = response.id.value;
228+
allocator.adoptFromCache(output, response.id, header::gSerializationMethodCCDB);
229+
}
221230
#if (FAIRMQ_VERSION_DEC >= 111000)
222231
result &= builder.second->Append();
223232
auto* value_builder = dynamic_cast<arrow::Int64Builder*>(builder.second->value_builder());
@@ -239,8 +248,7 @@ AlgorithmSpec AnalysisCCDBHelpers::fetchFromCCDB(ConfigContext const& /*ctx*/)
239248
arrow::ArrayVector arrays;
240249
std::ranges::for_each(builders, [&arrays](auto& builder) { arrays.push_back(*builder.second->Finish()); });
241250
auto outTable = arrow::Table::Make(schema, arrays);
242-
auto concrete = DataSpecUtils::asConcreteDataMatcher(spec);
243-
allocator.adopt(Output{concrete.origin, concrete.description, concrete.subSpec}, outTable);
251+
allocator.adopt(output, outTable);
244252
}
245253

246254
stats.updateStats({(int)ProcessingStatsId::CCDB_CACHE_FETCHED_BYTES, DataProcessingStats::Op::Set, (int64_t)helper->totalFetchedBytes});

Framework/CCDBSupport/src/CCDBFetcherHelper.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ auto CCDBFetcherHelper::populateCacheWith(std::shared_ptr<CCDBFetcherHelper> con
289289
O2_SIGNPOST_EVENT_EMIT(ccdb, sid, "populateCacheWith", "Reusing %{public}s for %{public}s (DPL id %" PRIu64 ")", path.data(), headers["ETag"].data(), cacheId.value);
290290
helper->mapURL2UUID[path].cacheHit++;
291291
responses.emplace_back(Response{.id = cacheId, .size = helper->mapURL2UUID[path].size, .request = nullptr});
292-
allocator.adoptFromCache(output, cacheId, header::gSerializationMethodCCDB);
292+
// allocator.adoptFromCache(output, cacheId, header::gSerializationMethodCCDB);
293293
// the outputBuffer was not used, can we destroy it?
294294
}
295295
O2_SIGNPOST_END(ccdb, sid, "populateCacheWith", "Finished populating cache with CCDB objects");

0 commit comments

Comments
 (0)