Skip to content
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

Closed

Conversation

fgiaimo
Copy link
Contributor

@fgiaimo fgiaimo commented Dec 7, 2016

Working for latest module started, responsiveness can be improved (later on)


// 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");
Copy link
Contributor

@HangYin2015 HangYin2015 Dec 8, 2016

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;
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@chrberger chrberger changed the title odcockpit performance monitor plugin 2016Q4.feature.odcockpit-performance-monitor-plugin Dec 8, 2016
// 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);
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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)

Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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");
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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();
Copy link
Contributor

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();
Copy link
Contributor

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();
Copy link
Contributor

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?

@chrberger
Copy link
Contributor

We have moved to libcluon and JS visualizations; is this PR still relevant?

@fgiaimo
Copy link
Contributor Author

fgiaimo commented Jul 24, 2019

I think not, it can be removed.

@chrberger chrberger closed this Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants