-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2016Q4.feature.odcockpit-performance-monitor-plugin #139
2016Q4.feature.odcockpit-performance-monitor-plugin #139
Conversation
….Q4.feature.odcockpit.performanceMonitor
….Q4.feature.odcockpit.performanceMonitor
… 2016.Q4.feature.odcockpit.performanceMonitor
|
||
// The number of processors currently online | ||
int numCPU = sysconf(_SC_NPROCESSORS_ONLN); | ||
if(numCPU == -1) OPENDAVINCI_CORE_THROW_EXCEPTION(IOException,"Could not get system info"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to enclose the exception statement in brackets (the same applies to other if conditions and for loops):
if(numCPU == -1){
...
}
proc_file>>str; | ||
proc_file>>chr; | ||
for(uint8_t i=0;i<11;++i) | ||
proc_file>>temp_buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more readable to put it in brackets
start_time=(double)temp_buffer/tickspersec; | ||
// Virtual memory size in bytes | ||
proc_file>>temp_buffer; | ||
total_vm_size=temp_buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are total_vm_size and resident_set_size of double type? Should they be integers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are doubles because they are assigned to the same array together with floating point % variables.
Integer (re-)conversion is performed at a later step.
// The number of processors currently online | ||
int numCPU = sysconf(_SC_NPROCESSORS_ONLN); | ||
if(numCPU == -1) { | ||
OPENDAVINCI_CORE_THROW_EXCEPTION(IOException,NO_SYS_INFO_EXC_MSG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be extract careful in this class as all modules depend on its flawless behavior.
I suggest to avoid throwing an exception here but adjust the code in such a way that it can handle ::sysconf(...) calls that might fail or return unexpected values without throwing an exception. @fgiaimo Could you please adjust the code accordingly? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a silent fail be better? The code can send out dummy values like -1 if there are errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or a boolean value is_valid can be added to the final statistics data structures (CPUConsumption and MEMConsumption)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is also if this call failed once, wouldn't it fail always? I.e., could you add a flag to avoid re-executing and failing to execute sysconf(...) repeatedly?
// Size of a page in bytes | ||
int pagesize_in_bytes = sysconf(_SC_PAGESIZE); | ||
if(pagesize_in_bytes < 1) { | ||
OPENDAVINCI_CORE_THROW_EXCEPTION(IOException,NO_SYS_INFO_EXC_MSG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
// The number of clock ticks per second | ||
long tickspersec = sysconf(_SC_CLK_TCK); | ||
if(tickspersec == -1) { | ||
OPENDAVINCI_CORE_THROW_EXCEPTION(IOException,NO_SYS_INFO_EXC_MSG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
double utime, stime, start_time, total_vm_size, resident_set_size; | ||
|
||
ifstream proc_file; | ||
proc_file.open("/proc/self/stat"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we should check if proc_file could successfully be opened.
proc_file>>temp_buffer; | ||
} | ||
// Amount of time that this process has been scheduled in user mode (in clock ticks) | ||
utime=(double)temp_buffer/tickspersec/numCPU; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tickspersec and numCPU will never be 0?
double cpu_time_delta=cpu_time_now-m_stats_cpu_time; | ||
double exec_time_delta=exec_time_now-m_stats_exc_time; | ||
double avg_cpu=m_stats_cpu_time/m_stats_exc_time*100.0; | ||
double ondemand_cpu=cpu_time_delta/exec_time_delta*100.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exec_time_delta will never be 0?
const string subentryCPU = sstr.str(); | ||
// search for the avg CPU stats container | ||
if (m_CPUStatisticsPerComponent.find(subentryCPU) == m_CPUStatisticsPerComponent.end()) { | ||
QTreeWidgetItem *newComponentStatisticsHeader = new QTreeWidgetItem(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't exhaust all memory here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume not, but how do I check for that?
const string subentryCPU = sstr.str(); | ||
// search for the od CPU stats container | ||
if (m_CPUStatisticsPerComponent.find(subentryCPU) == m_CPUStatisticsPerComponent.end()) { | ||
QTreeWidgetItem *newComponentStatisticsHeader = new QTreeWidgetItem(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't all memory here, right?
const string subentryMEM = sstr.str(); | ||
|
||
if (m_MEMStatisticsPerComponent.find(subentryMEM) == m_MEMStatisticsPerComponent.end()) { | ||
QTreeWidgetItem *newComponentStatisticsHeader = new QTreeWidgetItem(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't exhaust all memory here, right?
const string subentryMEM = sstr.str(); | ||
|
||
if (m_MEMStatisticsPerComponent.find(subentryMEM) == m_MEMStatisticsPerComponent.end()) { | ||
QTreeWidgetItem *newComponentStatisticsHeader = new QTreeWidgetItem(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't exhaust all memory here, right?
We have moved to libcluon and JS visualizations; is this PR still relevant? |
I think not, it can be removed. |
Working for latest module started, responsiveness can be improved (later on)