summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-11-16 19:12:41 +0100
committerBenBE <BenBE@geshi.org>2020-11-26 22:58:34 +0100
commit721d9112d9b44815a920302bf903cb2039f1ea37 (patch)
tree1f9d59021719b040e03428f69abbe29e69609729
parent7f18b352b0fc010efe5278ce32e01ed715ddd7ee (diff)
Only calculate M_LRS size every 5 seconds
-rw-r--r--linux/LinuxProcess.h1
-rw-r--r--linux/LinuxProcessList.c24
2 files changed, 22 insertions, 3 deletions
diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h
index 68c01ea5..e665502c 100644
--- a/linux/LinuxProcess.h
+++ b/linux/LinuxProcess.h
@@ -180,6 +180,7 @@ typedef struct LinuxProcess_ {
unsigned long ctxt_total;
unsigned long ctxt_diff;
char* secattr;
+ unsigned long long int last_mlrs_calctime;
} LinuxProcess;
#define Process_isKernelThread(_process) (((const LinuxProcess*)(_process))->isKernelThread)
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 6962527c..0f745c7b 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -555,18 +555,36 @@ static bool LinuxProcessList_readStatmFile(LinuxProcess* process, const char* di
if (!statmfile)
return false;
+ long tmp_m_lrs = 0;
int r = fscanf(statmfile, "%ld %ld %ld %ld %ld %ld %ld",
&process->super.m_virt,
&process->super.m_resident,
&process->m_share,
&process->m_trs,
- &process->m_lrs,
+ &tmp_m_lrs,
&process->m_drs,
&process->m_dt);
fclose(statmfile);
- if (r == 7 && !process->m_lrs && performLookup) {
- process->m_lrs = LinuxProcessList_calcLibSize(dirname, name);
+
+ if (r == 7) {
+ if (tmp_m_lrs) {
+ process->m_lrs = tmp_m_lrs;
+ } else if (performLookup) {
+ // Check if we really should recalculate the M_LRS value for this process
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ uint64_t timeInMilliSeconds = (uint64_t)tv.tv_sec * 1000ULL + (uint64_t)tv.tv_usec / 1000ULL;
+ uint64_t passedTimeInMs = timeInMilliSeconds - process->last_mlrs_calctime;
+
+ if(passedTimeInMs > 5000) {
+ process->last_mlrs_calctime = timeInMilliSeconds;
+ process->m_lrs = LinuxProcessList_calcLibSize(dirname, name);
+ }
+ } else {
+ // Keep previous value
+ }
}
+
return r == 7;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy