From 37de5639e80d86c93ff8b328286168f050a10f06 Mon Sep 17 00:00:00 2001 From: Jan Sobol Date: Thu, 26 Sep 2024 09:50:05 +0200 Subject: [PATCH] dpdk-ring - prefetch dequeued packets before processing --- input/dpdk-ring.cpp | 8 ++++++++ input/dpdk-ring.h | 1 + 2 files changed, 9 insertions(+) diff --git a/input/dpdk-ring.cpp b/input/dpdk-ring.cpp index 3af34e0a..6a612ce2 100644 --- a/input/dpdk-ring.cpp +++ b/input/dpdk-ring.cpp @@ -196,6 +196,7 @@ InputPlugin::Result DpdkRingReader::get(PacketBlock& packets) if (pkts_read_ == 0) { return Result::TIMEOUT; } + prefetchPackets(); for (auto i = 0; i < pkts_read_; i++) { parse_packet(&opt, m_parser_stats, @@ -256,4 +257,11 @@ void DpdkRingReader::getDynfieldInfo() } } +void DpdkRingReader::prefetchPackets() { + for (auto i = 0; i < pkts_read_; i++) { + __builtin_prefetch(mbufs_[i], 0, 2); + __builtin_prefetch((uint8_t*)mbufs_[i] + 64, 0, 2); + } +} + } // namespace ipxp \ No newline at end of file diff --git a/input/dpdk-ring.h b/input/dpdk-ring.h index 66fe2052..68dd9faf 100644 --- a/input/dpdk-ring.h +++ b/input/dpdk-ring.h @@ -152,6 +152,7 @@ class DpdkRingReader : public InputPlugin { telemetry::Content get_queue_telemetry(); void getDynfieldInfo(); + void prefetchPackets(); std::vector mbufs_; std::uint16_t pkts_read_;