From 86711a1332f7082a688ff68ad38f2641bd20ee26 Mon Sep 17 00:00:00 2001 From: cardigliano Date: Thu, 22 Oct 2015 01:43:41 +0200 Subject: [PATCH] pfring pkt acq: capture loop optimisation For each packet the capture module checks whether it is time to dump stats calling TimeGet(). TimeGet() is an expensive function using gettimeofday() or SCSpinLock() which affect performance. Since gettimeofday() is already called for setting packet timestamp, it is more efficient to use the packet timestamp directly. --- src/source-pfring.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/source-pfring.c b/src/source-pfring.c index 3e9db24b11..3e2ba6a856 100644 --- a/src/source-pfring.c +++ b/src/source-pfring.c @@ -301,7 +301,6 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot) struct pfring_pkthdr hdr; TmSlot *s = (TmSlot *)slot; time_t last_dump = 0; - struct timeval current_time; u_int buffer_size; u_char *pkt_buffer; @@ -365,10 +364,9 @@ TmEcode ReceivePfringLoop(ThreadVars *tv, void *data, void *slot) } /* Trigger one dump of stats every second */ - TimeGet(¤t_time); - if (current_time.tv_sec != last_dump) { + if (p->ts.tv_sec != last_dump) { PfringDumpCounters(ptv); - last_dump = current_time.tv_sec; + last_dump = p->ts.tv_sec; } } else { SCLogError(SC_ERR_PF_RING_RECV,"pfring_recv error %" PRId32 "", r); -- 2.47.2