FreeBSD Bugzilla – Attachment 215537 Details for
Bug 246929
net/ntopng: High CPU usage after update to v4
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix for excessive CPU usage
ntopng.patch (text/plain), 5.20 KB, created by
Guido Falsi
on 2020-06-14 09:09:15 UTC
(
hide
)
Description:
Fix for excessive CPU usage
Filename:
MIME Type:
Creator:
Guido Falsi
Created:
2020-06-14 09:09:15 UTC
Size:
5.20 KB
patch
obsolete
>Index: Makefile >=================================================================== >--- Makefile (revision 538713) >+++ Makefile (working copy) >@@ -2,7 +2,7 @@ > # $FreeBSD$ > > PORTNAME= ntopng >-PORTVERSION= 4.0.d20200530 >+PORTVERSION= 4.0.d20200608 > PORTEPOCH= 1 > CATEGORIES= net > >@@ -36,7 +36,7 @@ > > USE_GITHUB= yes > GH_ACCOUNT= ntop >-GH_TAGNAME= 66a6a44 >+GH_TAGNAME= a020c6e > > CPE_VENDOR= ntop > >Index: distinfo >=================================================================== >--- distinfo (revision 538713) >+++ distinfo (working copy) >@@ -1,3 +1,3 @@ >-TIMESTAMP = 1590935345 >-SHA256 (ntop-ntopng-4.0.d20200530-66a6a44_GH0.tar.gz) = ee56a7418d46c40e5375dde963fd06d773c0c8237b77cab1208c93e8e525f85c >-SIZE (ntop-ntopng-4.0.d20200530-66a6a44_GH0.tar.gz) = 43398672 >+TIMESTAMP = 1591913842 >+SHA256 (ntop-ntopng-4.0.d20200608-a020c6e_GH0.tar.gz) = df14f9ac370212e01dbef38f06d6837f9476bc76adaa688d2fa65fa47e6d26d4 >+SIZE (ntop-ntopng-4.0.d20200608-a020c6e_GH0.tar.gz) = 43401037 >Index: files/patch-fix-CPU-usage >=================================================================== >--- files/patch-fix-CPU-usage (nonexistent) >+++ files/patch-fix-CPU-usage (working copy) >@@ -0,0 +1,117 @@ >+diff --git a/include/Utils.h b/include/Utils.h >+index 75238911d..1b584883d 100755 >+--- include/Utils.h >++++ include/Utils.h >+@@ -58,6 +58,7 @@ public: >+ static u_int32_t hashString(const char * const s); >+ static float timeval2ms(struct timeval *tv); >+ static float msTimevalDiff(const struct timeval *end, const struct timeval *begin); >++ static u_int32_t usecTimevalDiff(const struct timeval *end, const struct timeval *begin); >+ static size_t file_write(const char *path, const char *content, size_t content_len); >+ static size_t file_read(const char *path, char **content); >+ static bool file_exists(const char * const path); >+diff --git a/src/Ntop.cpp b/src/Ntop.cpp >+index 5ca6a1f69..3cdfda3b1 100644 >+--- src/Ntop.cpp >++++ src/Ntop.cpp >+@@ -547,7 +547,7 @@ void Ntop::start() { >+ _usleep((5 - begin.tv_sec % 5) * 1e6 - begin.tv_usec); >+ >+ while((!globals->isShutdown()) && (!globals->isShutdownRequested())) { >+- u_long nap = ntop->getPrefs()->get_housekeeping_frequency() * 1e6; >++ const u_int32_t nap_usec = ntop->getPrefs()->get_housekeeping_frequency() * 1e6; >+ >+ gettimeofday(&begin, NULL); >+ >+@@ -566,35 +566,39 @@ void Ntop::start() { >+ >+ runHousekeepingTasks(); >+ >++#ifndef __linux__ >++ gettimeofday(&end, NULL); >++ >++ usec_diff = Utils::usecTimevalDiff(&end, &begin); >++ >++ if(usec_diff < nap_usec) >++ _usleep(nap_usec-usec_diff); >++#else >+ do { >+ gettimeofday(&end, NULL); >++ usec_diff = Utils::usecTimevalDiff(&end, &begin); >+ >+- usec_diff = (end.tv_sec * 1e6) + end.tv_usec - (begin.tv_sec * 1e6) - begin.tv_usec; >+- >+- if(usec_diff < nap) { >++ if(usec_diff < nap_usec) { >+ int maxfd = 0; >+ fd_set rset; >+ struct timeval tv; >+ >+ #if 0 >+- ntop->getTrace()->traceEvent(TRACE_DEBUG, >++ ntop->getTrace()->traceEvent(TRACE_NORMAL, >+ "Sleeping %i microsecods before doing the chores.", >+- (nap - usec_diff)); >++ (nap_usec - usec_diff)); >+ #endif >+ >+ FD_ZERO(&rset); >+ >+-#ifdef __linux__ >+ if(inotify_fd > 0) { >+ FD_SET(inotify_fd, &rset); >+ maxfd = inotify_fd; >+ } >+-#endif >+ >+- tv.tv_sec = 0, tv.tv_usec = (nap - usec_diff); >++ tv.tv_sec = 0, tv.tv_usec = (nap_usec - usec_diff); >+ >+ if(select(maxfd + 1, &rset, NULL, NULL, &tv) > 0) { >+-#ifdef __linux__ >+ if(FD_ISSET(inotify_fd, &rset)) { >+ char buffer[EVENT_BUF_LEN]; >+ >+@@ -604,10 +608,10 @@ void Ntop::start() { >+ ntop->getTrace()->traceEvent(TRACE_DEBUG, "Directory changed"); >+ reloadPeriodicScripts(); >+ } >+-#endif >+ } >+ } >+- } while(usec_diff < nap); >++ } while(usec_diff < nap_usec); >++#endif >+ } >+ } >+ >+diff --git a/src/Utils.cpp b/src/Utils.cpp >+index 4761c843f..4e3b50fc2 100755 >+--- src/Utils.cpp >++++ src/Utils.cpp >+@@ -436,6 +436,25 @@ u_int32_t Utils::timeval2usec(const struct timeval *tv) { >+ >+ /* ****************************************************** */ >+ >++u_int32_t Utils::usecTimevalDiff(const struct timeval *end, const struct timeval *begin) { >++ if((end->tv_sec == 0) && (end->tv_usec == 0)) >++ return(0); >++ else { >++ struct timeval res; >++ >++ res.tv_sec = end->tv_sec - begin->tv_sec; >++ if(begin->tv_usec > end->tv_usec) { >++ res.tv_usec = end->tv_usec + 1000000 - begin->tv_usec; >++ res.tv_sec--; >++ } else >++ res.tv_usec = end->tv_usec - begin->tv_usec; >++ >++ return((res.tv_sec*1000000) + (res.tv_usec)); >++ } >++} >++ >++/* ****************************************************** */ >++ >+ float Utils::msTimevalDiff(const struct timeval *end, const struct timeval *begin) { >+ if((end->tv_sec == 0) && (end->tv_usec == 0)) >+ return(0); > >Property changes on: files/patch-fix-CPU-usage >___________________________________________________________________ >Added: fbsd:nokeywords >## -0,0 +1 ## >+yes >\ No newline at end of property >Added: svn:eol-style >## -0,0 +1 ## >+native >\ No newline at end of property >Added: svn:mime-type >## -0,0 +1 ## >+text/plain >\ No newline at end of property
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 246929
:
215461
| 215537