PDA

View Full Version : XORG using a lot of CPU resources



eduluz
8th June 2010, 17:46
Hello Folks,

I am having a performance problem.

The application I'm working on was fine until I put a timer to call
update() of QLabel every 300ms.

Every time I run my application the initial CPU usage of it is about
60% - 70% and Xorg CPU usage is about 20% - 30% but that is normal.
When the timer starts to call update of QLabel, the Xorg CPU usage
starts increasing and reach almost 100% of CPU in 10 minutes and the
CPU usage of my application falls to 4% - 5%. That happens when I use
default graphics system (that would be the native??). When I run my
app using "-graphicssystem raster" the problem disapears. Using
"-graphicssystem opengl" crashes the system.

OS : Ubuntu 9.04 (linux kernel 2.6.28-15-generic)
Qt: 4.6.2
X.Org X Server: 1.6.0
GPU: GeForce 7300 SE/7200 GS
NVIDIA Driver Version: 180.44

I need to know what is going on here. Any help will be appreciated.

Regards,
Eduardo Luz

tbscope
8th June 2010, 18:31
The application I'm working on was fine until I put a timer to call
update() of QLabel every 300ms.

What does the update do? Or, what are you painting on the label?
Can you show some code? Maybe some parts can be performed more efficiently

eduluz
8th June 2010, 18:36
The timer calls that code :


void CMessageLabel::checkAlarmDutyCycle( )
{
if(m_currentMsg.message().isNull()) {
clear();
update();
m_alarmDutyOn = false;
}
else {
if(m_currentMsg.state() == SILENCED){
m_alarmDutyOn = true;
update();
}
else {
if(m_currentMsg.priority() == Monitoring::HIGH_PRIORITY) {
m_alarmDutyOn = !m_alarmDutyOn;
update();
}
else if(m_currentMsg.priority() == Monitoring::MEDIUM_PRIORITY) {
m_alarmDutyOn = !m_alarmDutyOn;
update();
}
else if(m_currentMsg.priority() == Monitoring::LOW_PRIORITY) {
m_alarmDutyOn = true;
update();
}
}
}
}

and my paint event is overwrited to change the background color of the Qlabel :


void CMessageLabel::paintEvent(QPaintEvent* e)
{
QPainter painter(this);
QRect rect = this->rect();

// define fundo do display
if( m_currentMsg.message().isNull() ) {
// sem fundo
}
else if(m_currentMsg.priority() == Monitoring::HIGH_PRIORITY) {
// cor de fundo vermelha - frequência 1.5Hz duty cycle = 50%

qDebug("checkAlarmDutyCycle:HIGH_PRIORITY");

if(m_alarmDutyOn) {
// Alterna a cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(0,0,0 ));
setPalette(palette);

if(m_currentMsg.state() != SILENCED) {
painter.setBrush(QBrush(QColor("#ff0000"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width (),rect.height());
}
else {
painter.setBrush(QBrush(QColor("#880000"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width (),rect.height());
}
}
else {
// não preenche o fundo

// Alterna a cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(255,2 55,255));
setPalette(palette);
}
}
else if(m_currentMsg.priority() == Monitoring::MEDIUM_PRIORITY) {
// cor de fundo amarela - frequência 0.5Hz duty cycle = 50%
if(m_alarmDutyOn) {
// alterna cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(0,0,0 ));
setPalette(palette);

if(m_currentMsg.state() != SILENCED) {
painter.setBrush(QBrush(QColor("#dddd00"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width (),rect.height());
}
else {
painter.setBrush(QBrush(QColor("#888800"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width (),rect.height());
}
}
else {
// não preenche o fundo
// Alterna a cor da fonte para melhorar visibilidade
QPalette palette = this->palette();
palette.setColor(QPalette::WindowText,QColor(255,2 55,255));
setPalette(palette);
}
}
else if(m_currentMsg.priority() == Monitoring::LOW_PRIORITY) {
if(m_currentMsg.state() != SILENCED) {
// cor de fundo ciano - constante
painter.setBrush(QBrush(QColor("#00ffff"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width (),rect.height());
}
else {
// cor de fundo ciano - constante
painter.setBrush(QBrush(QColor("#008888"), Qt::SolidPattern));
painter.drawRect(rect.left(),rect.top(),rect.width (),rect.height());
}
}

// executa o método da classe base
QLabel::paintEvent(e);
// QWidget::paintEvent(e);

}

Regards,