From 8dd8ee4d92d4b1c9c48723415f182f5330cc9364 Mon Sep 17 00:00:00 2001 From: Nigel Kukard <nkukard@lbsd.net> Date: Sun, 12 Jan 2014 21:10:45 +0000 Subject: [PATCH] Set maximum flushed stats to 10k --- opentrafficshaper/plugins/statistics/statistics.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/opentrafficshaper/plugins/statistics/statistics.pm b/opentrafficshaper/plugins/statistics/statistics.pm index cd546de..cbedebe 100644 --- a/opentrafficshaper/plugins/statistics/statistics.pm +++ b/opentrafficshaper/plugins/statistics/statistics.pm @@ -72,6 +72,8 @@ use constant { STATISTICS_DIR_TX => 1, STATISTICS_DIR_RX => 2, + + STATISTICS_MAXFLUSH_PER_PERIOD => 10000, }; @@ -349,9 +351,15 @@ sub _session_tick my $sthStatsBasicCleanup = $statsPreparedStatements->{'stats_basic_cleanup'}; # Even out flushing over 10s to absorb spikes - my $maxFlush = int(@{$statsQueue} / 10) + 100; + my $totalFlush = @{$statsQueue}; + my $maxFlush = int($totalFlush / 10) + 100; my $numFlush = 0; + # Make sure we don't write more than 10k entries per pass + if ($maxFlush > STATISTICS_MAXFLUSH_PER_PERIOD) { + $maxFlush = STATISTICS_MAXFLUSH_PER_PERIOD; + } + # Loop and build the data to create our multi-insert my (@insertHolders,@insertBasicHolders); my (@insertData,@insertBasicData); @@ -418,7 +426,7 @@ sub _session_tick my $timediff2 = tv_interval($timer1,$timer2); $logger->log(LOG_INFO,"[STATISTICS] Total stats flush time %s/%s records: %s", $numFlush, - $maxFlush, + $totalFlush, sprintf('%.3fs',$timediff2) ); } -- GitLab