[Oisf-devel] [PATCH 2/2] Flow: Increase refresh timer

Victor Julien victor at inliniac.net
Fri Dec 31 16:52:51 UTC 2010


On 12/31/2010 01:15 PM, Eric Leblond wrote:
> FlowManagerThread function was running its check after a 10
> microseconds sleep. nanosleep system call were causing a
> consequent CPU load on my computer running running no trafic.
> This patch modifies the timer to a default of 10 ms.
> 
> It also suppress a usleep(1) used in pcap file mode. This delay
> seems to short to really bring something.

This part of the patch seems problematic. In testing it seems almost 25%
slower when processing pcaps.

Rejecting this for now...

Cheers,
Victor


> Signed-off-by: Eric Leblond <eric at regit.org>
> ---
>  src/flow.c |   17 ++++++++++-------
>  1 files changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/src/flow.c b/src/flow.c
> index d955529..9c2b53b 100644
> --- a/src/flow.c
> +++ b/src/flow.c
> @@ -955,6 +955,10 @@ void FlowShutdown(void) {
>      }
>  }
>  
> +
> +#define FLOW_SLEEP_INTERVAL 10 * 1000
> +#define FLOW_UPDATE_INTERVAL FLOW_SLEEP_INTERVAL * 10
> +
>  /** \brief Thread that manages the various queue's and removes timed out flows.
>   *  \param td ThreadVars casted to void ptr
>   *
> @@ -995,7 +999,7 @@ void *FlowManagerThread(void *td)
>      {
>          TmThreadTestThreadUnPaused(th_v);
>  
> -        if (sleeping >= 100 || flow_flags & FLOW_EMERGENCY)
> +        if (sleeping >= FLOW_UPDATE_INTERVAL || flow_flags & FLOW_EMERGENCY)
>          {
>              if (flow_flags & FLOW_EMERGENCY) {
>                  emerg = TRUE;
> @@ -1075,8 +1079,8 @@ void *FlowManagerThread(void *td)
>          }
>  
>          if (run_mode != MODE_PCAP_FILE) {
> -            usleep(10);
> -            sleeping += 10;
> +            usleep(FLOW_SLEEP_INTERVAL);
> +            sleeping += FLOW_SLEEP_INTERVAL;
>          } else {
>              /* If we are reading a pcap, how long the pcap timestamps
>               * says that has passed */
> @@ -1085,8 +1089,8 @@ void *FlowManagerThread(void *td)
>  
>              if (tsdiff.tv_sec == ts.tv_sec &&
>                  tsdiff.tv_usec > ts.tv_usec &&
> -                tsdiff.tv_usec - ts.tv_usec < 10) {
> -                /* if it has passed less than 10 usec, sleep that usecs */
> +                tsdiff.tv_usec - ts.tv_usec < FLOW_SLEEP_INTERVAL) {
> +                /* if it has passed less than sleep interval usec, sleep that usecs */
>                  sleeping += tsdiff.tv_usec - ts.tv_usec;
>                  usleep(tsdiff.tv_usec - ts.tv_usec);
>              } else {
> @@ -1096,8 +1100,7 @@ void *FlowManagerThread(void *td)
>                  else if (tsdiff.tv_sec == ts.tv_sec + 1)
>                      sleeping += tsdiff.tv_usec + (1000000 - ts.tv_usec);
>                  else
> -                    sleeping += 100;
> -                usleep(1);
> +                    sleeping += FLOW_UPDATE_INTERVAL;
>              }
>          }
>      }


-- 
---------------------------------------------
Victor Julien
http://www.inliniac.net/
PGP: http://www.inliniac.net/victorjulien.asc
---------------------------------------------




More information about the Oisf-devel mailing list