Skip to content

fix: resolve #397 — bandwhich CPU utilization is too high#506

Open
chinhkrb113 wants to merge 1 commit into
imsnif:mainfrom
chinhkrb113:improve/quality/avoid-packet-capture-busy-polling
Open

fix: resolve #397 — bandwhich CPU utilization is too high#506
chinhkrb113 wants to merge 1 commit into
imsnif:mainfrom
chinhkrb113:improve/quality/avoid-packet-capture-busy-polling

Conversation

@chinhkrb113
Copy link
Copy Markdown

Summary

Packet capture code can consume an entire core if it polls the capture device in non-blocking mode without sleeping. If pcap/pnet capture is configured as non-blocking and the sniffer repeatedly calls next_packet/next in a loop, it will spin when no packets are available. The sniffer should either use blocking packet reads or apply a bounded timeout/backoff

Fixes #397

Changes

  • src/network/sniffer.rs

Why

src/network/sniffer.rs: Packet capture code can consume an entire core if it polls the capture device in non-blocking mode without sleeping. If pcap/pnet capture is configured as non-blocking and the sniffer repeatedly calls next_packet/next in a loop, it will spin when no packets are available. The sniffer should either use blocking packet reads or apply a bounded timeout/backoff.

Fixes imsnif#397

Signed-off-by: ChinhLee <76194645+chinhkrb113@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bandwhich CPU utilization is too high

1 participant