Merge lp:~vanvugt/compiz/fix-1095001 into lp:compiz/0.9.9

Proposed by Daniel van Vugt
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3534
Merged at revision: 3533
Proposed branch: lp:~vanvugt/compiz/fix-1095001
Merge into: lp:compiz/0.9.9
Diff against target: 85 lines (+28/-5)
3 files modified
plugins/opengl/src/paint.cpp (+12/-3)
plugins/opengl/src/privates.h (+3/-0)
plugins/opengl/src/screen.cpp (+13/-2)
To merge this branch: bzr merge lp:~vanvugt/compiz/fix-1095001
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+141551@code.launchpad.net

Commit message

Avoid calling code that results in calls to regexec as much as possible.
Regular expression matching is too expensive to do very often and compiz
was spending 31% of its CPU time in regexec().
(LP: #1095001)

Description of the change

Before: 31%
After: 0.01%

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

2 if (unredirectFS &&
23 !blacklisted &&
24 - unredirectable.evaluate (w) &&
25 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
26 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
27 - fs.isCoveredBy (w->region (), flags))
28 + fs.isCoveredBy (w->region (), flags) &&
29 + (!cw->redirected () || unredirectable.evaluate (w)))

It might be worth trying to fix that wall of conditionals to be more readable in future too.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/opengl/src/paint.cpp'
--- plugins/opengl/src/paint.cpp 2012-12-13 10:12:23 +0000
+++ plugins/opengl/src/paint.cpp 2013-01-01 10:11:23 +0000
@@ -354,22 +354,31 @@
354 if (w->alpha ())354 if (w->alpha ())
355 flags |= FullscreenRegion::Alpha;355 flags |= FullscreenRegion::Alpha;
356 356
357 CompositeWindow *cw = CompositeWindow::get (w);
358
357 /*359 /*
358 * Windows with alpha channels can partially occlude windows360 * Windows with alpha channels can partially occlude windows
359 * beneath them and so neither should be unredirected in that case.361 * beneath them and so neither should be unredirected in that case.
362 *
363 * Performance note: unredirectable.evaluate is SLOW because it
364 * involves regex matching. Too slow to do on every window for
365 * every frame. So we only call it if a window is redirected AND
366 * potentially needs unredirecting. This means changes to
367 * unredirect_match while a window is unredirected already may not
368 * take effect until it is un-fullscreened again. But that's better
369 * than the high price of regex matching on every frame.
360 */370 */
361 if (unredirectFS &&371 if (unredirectFS &&
362 !blacklisted &&372 !blacklisted &&
363 unredirectable.evaluate (w) &&
364 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&373 !(mask & PAINT_SCREEN_TRANSFORMED_MASK) &&
365 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&374 !(mask & PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK) &&
366 fs.isCoveredBy (w->region (), flags))375 fs.isCoveredBy (w->region (), flags) &&
376 (!cw->redirected () || unredirectable.evaluate (w)))
367 {377 {
368 unredirected.insert (w);378 unredirected.insert (w);
369 }379 }
370 else380 else
371 {381 {
372 CompositeWindow *cw = CompositeWindow::get (w);
373 if (!cw->redirected ())382 if (!cw->redirected ())
374 {383 {
375 if (fs.allowRedirection (w->region ()))384 if (fs.allowRedirection (w->region ()))
376385
=== modified file 'plugins/opengl/src/privates.h'
--- plugins/opengl/src/privates.h 2012-12-13 10:12:23 +0000
+++ plugins/opengl/src/privates.h 2013-01-01 10:11:23 +0000
@@ -222,6 +222,9 @@
222 CompSize rootPixmapSize;222 CompSize rootPixmapSize;
223223
224 const char *glVendor, *glRenderer, *glVersion;224 const char *glVendor, *glRenderer, *glVersion;
225
226 mutable CompString prevRegex;
227 mutable bool prevBlacklisted;
225};228};
226229
227class PrivateGLWindow :230class PrivateGLWindow :
228231
=== modified file 'plugins/opengl/src/screen.cpp'
--- plugins/opengl/src/screen.cpp 2012-12-12 07:33:12 +0000
+++ plugins/opengl/src/screen.cpp 2013-01-01 10:11:23 +0000
@@ -1248,7 +1248,9 @@
1248 rootPixmapSize (),1248 rootPixmapSize (),
1249 glVendor (NULL),1249 glVendor (NULL),
1250 glRenderer (NULL),1250 glRenderer (NULL),
1251 glVersion (NULL)1251 glVersion (NULL),
1252 prevRegex (),
1253 prevBlacklisted (false)
1252{1254{
1253 ScreenInterface::setHandler (screen);1255 ScreenInterface::setHandler (screen);
1254}1256}
@@ -2155,7 +2157,16 @@
2155bool2157bool
2156PrivateGLScreen::driverIsBlacklisted (const char *regex) const2158PrivateGLScreen::driverIsBlacklisted (const char *regex) const
2157{2159{
2158 return blacklisted (regex, glVendor, glRenderer, glVersion);2160 /*
2161 * regex matching is VERY expensive, so only do it when the result might
2162 * be different to last time. The gl* variables never change value...
2163 */
2164 if (prevRegex != regex)
2165 {
2166 prevBlacklisted = blacklisted (regex, glVendor, glRenderer, glVersion);
2167 prevRegex = regex;
2168 }
2169 return prevBlacklisted;
2159}2170}
21602171
2161GLTexture::BindPixmapHandle2172GLTexture::BindPixmapHandle

Subscribers

People subscribed via source and target branches