Skip to content

Commit

Permalink
dpdk-ring - prefetch dequeued packets before processing
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSableCZ committed Sep 26, 2024
1 parent 5adbd36 commit 37de563
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions input/dpdk-ring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions input/dpdk-ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class DpdkRingReader : public InputPlugin {

telemetry::Content get_queue_telemetry();
void getDynfieldInfo();
void prefetchPackets();

std::vector<rte_mbuf *> mbufs_;
std::uint16_t pkts_read_;
Expand Down

0 comments on commit 37de563

Please sign in to comment.