Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPL: extra signposts for InitTask callback #13793

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Framework/Core/src/DataProcessingDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,9 @@ void DataProcessingDevice::InitTask()
auto ref = ServiceRegistryRef{mServiceRegistry};
auto& deviceContext = ref.get<DeviceContext>();
auto& context = ref.get<DataProcessorContext>();

O2_SIGNPOST_ID_FROM_POINTER(cid, device, &context);
O2_SIGNPOST_START(device, cid, "InitTask", "Entering InitTask callback.");
auto& spec = getRunningDevice(mRunningDevice, mServiceRegistry);
auto distinct = DataRelayerHelpers::createDistinctRouteIndex(spec.inputs);
auto& state = ref.get<DeviceState>();
Expand Down Expand Up @@ -1098,10 +1101,13 @@ void DataProcessingDevice::InitTask()
// We will get there.
this->fillContext(mServiceRegistry.get<DataProcessorContext>(ServiceRegistry::globalDeviceSalt()), deviceContext);

O2_SIGNPOST_END(device, cid, "InitTask", "Exiting InitTask callback waiting for the remaining region callbacks.");

auto hasPendingEvents = [&mutex = mRegionInfoMutex, &pendingRegionInfos = mPendingRegionInfos](DeviceContext& deviceContext) {
std::lock_guard<std::mutex> lock(mutex);
return (pendingRegionInfos.empty() == false) || deviceContext.expectedRegionCallbacks > 0;
};
O2_SIGNPOST_START(device, cid, "InitTask", "Waiting for registation events.");
/// We now run an event loop also in InitTask. This is needed to:
/// * Make sure region registration callbacks are invoked
/// on the main thread.
Expand All @@ -1111,10 +1117,12 @@ void DataProcessingDevice::InitTask()
uv_run(state.loop, UV_RUN_ONCE);
// Handle callbacks if any
{
O2_SIGNPOST_EVENT_EMIT(device, cid, "InitTask", "Memory registration event received.");
std::lock_guard<std::mutex> lock(mRegionInfoMutex);
handleRegionCallbacks(mServiceRegistry, mPendingRegionInfos);
}
}
O2_SIGNPOST_END(device, cid, "InitTask", "Done waiting for registration events.");
}

void DataProcessingDevice::fillContext(DataProcessorContext& context, DeviceContext& deviceContext)
Expand Down
Loading