fako1024/slimcap

Consider removing capture.Packet interface

Closed this issue · 1 comments

When analyzing the performance of packet populating in els0r/goProbe#38 it turned out that in tight loops / under heavy load there seems to be a substantial overhead when accessing interface methods from packets returned by any of the capture sources (wrapped behind the capture.Packet interface.
It might be prudent to assess if replacing that interface with a fixed struct instead that still allows enforcing a certain "interface" without actually having to use one.

DoD

  • Assess feasibility of replacing capture.Packet with a struct
  • Adapt goProbe capture accordingly
  • benchmark / compare

Removal of the interface yields an improvement by about 5% (only from accessing data from capture.Packet, there will probably be some small improvements in the capture part as well) in a real-life scenario like https://github.com/els0r/goProbe:

cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
                                                                    │ /tmp/iface.txt │          /tmp/noiface.txt          │
                                                                    │     sec/op     │   sec/op     vs base               │
Population/10.0.0.1:0->4.5.6.7:53_17_0000000000000000000000000000-4      22.56n ± 1%   21.53n ± 2%  -4.57% (p=0.000 n=10)