Gandem / bonjour-reflector

A reflector that forwards mdns packets between VLANs - like avahi-reflector but with fine-grained control !
MIT License
175 stars 36 forks source link

High CPU usage #20

Closed antoinedeschenes closed 6 years ago

antoinedeschenes commented 6 years ago

CPU usage seems to be quite high, I compiled bonjour-reflector on MIPS architecture and I get 100% load (of course it's not a very powerful CPU to start with...). I'm wondering if packet processing could be threaded, source VLANs filtered earlier or something.

Gandem commented 6 years ago

Thank you for your interest in this project !

I grabbed a quick cpu profile of a running application :

cgo

What is taking the large majority of the cpu time is the packet capture with pcap. This definitely needs a more thorough investigation.

antoinedeschenes commented 6 years ago

I see, I built a version using afpacket instead of libpcap earlier this week but didn't try it yet on a VLAN trunk. (At least I saw some logs going on my home network)

Gandem commented 6 years ago

This should be fixed, as we updated gopacket so we can benefit from https://github.com/google/gopacket/commit/fa2cf54d72acd452a072ef005e231b5d7a7b5ebd

If you still have any problem, please feel free to reopen the issue !

antoinedeschenes commented 6 years ago

Hi, this seems to work really well, CPU usage has gone from 100% to <1%. My afpacket tests turned out to work on x86 but didn't work at all on the mips router

L3Nerd commented 5 years ago

Hey there,

I'm running bonjour-reflector on a homeserver with constant network-load on a single interface. The server traffic is running on the interface with an untagged vlan and all wifi-vlans are transmitted tagged to the server.

An average of approx. 70MBit/s is running constantly through that interface, causing an average 20% load on the bonjour-reflector process.

Was anyone investigating on that issue further since last year?

L3Nerd commented 5 years ago

Nevermind - https://github.com/Gandem/bonjour-reflector/pull/23 seems to resolve that issue, will use that until merging.

antoinedeschenes commented 5 years ago

In my case the gopacket update on master was sufficient, but I was running bonjour-reflector on a separate interface passively listening for multicast traffic. Now of course BPF should be a lot more efficient.