Add one more check for paints taking too much time, this time

also detect not-so-bad-but-still-slow paint times over a longer
period of time, i.e. the old check is for systems which are pathetically
slow, this one is for systems that are just slow. Possibly may need
tweaking for cases like high system load, but right now it seems
that e.g. a compilation running cannot trigger this check because
it cannot cause many long repaints in a row.


svn path=/trunk/KDE/kdebase/workspace/; revision=866636
icc-effect-5.14.5
Luboš Luňák 2008-10-01 14:29:56 +00:00
parent b93766efc8
commit 9ad12bc391
2 changed files with 30 additions and 10 deletions

View File

@ -449,19 +449,40 @@ void Workspace::checkCompositePaintTime( int msec )
{
if( options->disableCompositingChecks )
return;
composite_paint_times.enqueue( msec );
if( composite_paint_times.count() > 3 )
composite_paint_times.dequeue();
if( composite_paint_times.count() < 3 )
return;
composite_paint_times.prepend( msec );
bool tooslow = false;
// If last 3 paints were way too slow, disable and warn.
// 1 second seems reasonable, it's not that difficult to get relatively high times
// with high system load.
const int MAX_TIME = 1000;
if( composite_paint_times[ 0 ] > MAX_TIME && composite_paint_times[ 1 ] > MAX_TIME
&& composite_paint_times[ 2 ] > MAX_TIME )
const int MAX_LONG_PAINT = 1000;
if( composite_paint_times.count() >= 3 && composite_paint_times[ 0 ] > MAX_LONG_PAINT
&& composite_paint_times[ 1 ] > MAX_LONG_PAINT && composite_paint_times[ 2 ] > MAX_LONG_PAINT )
{
kDebug( 1212 ) << "Too long paint times, suspending";
tooslow = true;
}
// If last 15 seconds all paints (all of them) were quite slow, disable and warn too. Quite slow being 0,1s
// should be reasonable, that's 10fps and having constant 10fps is bad.
// This may possibly trigger also when activating an expensive effect, so this may need tweaking.
const int MAX_SHORT_PAINT = 100;
const int SHORT_TIME = 15000; // 15 sec
int time = 0;
foreach( int t, composite_paint_times )
{
if( t < MAX_SHORT_PAINT )
break;
time += t;
if( time > SHORT_TIME ) // all paints in the given time were long
{
kDebug( 1212 ) << "Long paint times for long time, suspending";
tooslow = true;
break;
}
}
if( composite_paint_times.count() > 1000 )
composite_paint_times.removeLast();
if( tooslow )
{
QTimer::singleShot( 0, this, SLOT( suspendCompositing()));
QString shortcut = i18n( "Empty" );
if( KAction* action = qobject_cast<KAction*>( keys->action("Suspend Compositing")))

View File

@ -30,7 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kxmessages.h>
#include <QDateTime>
#include <kmanagerselection.h>
#include <qqueue.h>
#include "utils.h"
#include "kdecoration.h"
@ -753,7 +752,7 @@ class Workspace : public QObject, public KDecorationDefines
QPushButton *transButton;
QTimer unredirectTimer;
bool forceUnredirectCheck;
QQueue< int > composite_paint_times;
QList< int > composite_paint_times;
private:
friend bool performTransiencyCheck();