Skip to content

Commit 5215528

Browse files
committed
Avoid memory churn when looking up channel
1 parent cbe36d6 commit 5215528

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Framework/Core/include/Framework/ExternalFairMQDeviceProxy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace o2::framework
2222

2323
/// A callback function to retrieve the fair::mq::Channel name to be used for sending
2424
/// messages of the specified OutputSpec
25-
using ChannelRetriever = std::function<std::string(OutputSpec const&, DataProcessingHeader::StartTime)>;
25+
using ChannelRetriever = std::function<std::string const&(OutputSpec const&, DataProcessingHeader::StartTime)>;
2626
/// The callback which actually does the heavy lifting of converting the input data into
2727
/// DPL messages. The callback is invoked with the following parameters:
2828
/// @param timingInfo is the timing information of the current timeslice
@@ -144,6 +144,6 @@ DataProcessorSpec specifyFairMQDeviceMultiOutputProxy(char const* label,
144144
const char* defaultChannelConfig,
145145
ChannelSelector channelSelector = defaultOutputProxyChannelSelector);
146146

147-
} // namespace o2
147+
} // namespace o2::framework
148148

149149
#endif // FRAMEWORK_RAWDEVICESOURCE_H

Framework/Core/src/ExternalFairMQDeviceProxy.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,14 +752,15 @@ DataProcessorSpec specifyExternalFairMQDeviceProxy(char const* name,
752752
outputChannels = std::move(outputChannels)](ServiceRegistryRef ref, TimingInfo& timingInfo, fair::mq::Parts& inputs, int, size_t ci, bool newRun) -> bool {
753753
auto* device = ref.get<RawDeviceService>().device();
754754
// pass a copy of the outputRoutes
755-
auto channelRetriever = [&outputRoutes](OutputSpec const& query, DataProcessingHeader::StartTime timeslice) -> std::string {
755+
auto channelRetriever = [&outputRoutes](OutputSpec const& query, DataProcessingHeader::StartTime timeslice) -> std::string const& {
756+
static std::string emptyChannel = "";
756757
for (auto& route : outputRoutes) {
757758
LOG(debug) << "matching: " << DataSpecUtils::describe(query) << " to route " << DataSpecUtils::describe(route.matcher);
758759
if (DataSpecUtils::match(route.matcher, query) && ((timeslice % route.maxTimeslices) == route.timeslice)) {
759760
return route.channel;
760761
}
761762
}
762-
return {""};
763+
return emptyChannel;
763764
};
764765

765766
std::string const& channel = channels[ci];

Framework/Core/test/benchmark_ExternalFairMQDeviceProxies.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ std::vector<DataProcessorSpec> defineDataProcessing(ConfigContext const& config)
483483
// Note: we want to run both the output and input proxy in the same workflow and thus we need
484484
// different data identifiers and change the data origin in the forwarding
485485
OutputSpec query{"PRX", dh->dataDescription, dh->subSpecification};
486-
auto channelName = channelRetriever(query, dph->startTime);
486+
auto const& channelName = channelRetriever(query, dph->startTime);
487487
bool isData = DataSpecUtils::match(OutputSpec{"TST", "DATA", 0}, dh->dataOrigin, dh->dataDescription, dh->subSpecification);
488488
// for the configured data channel we require the channel name, the EOS message containing
489489
// the forwarded SourceInfoHeader created by the output proxy will be skipped here since the

0 commit comments

Comments
 (0)