Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1391)

Issue 5501066: posix: Avoid static initializers in static/global mutexes (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 11 months ago by digit
Modified:
12 years, 10 months ago
Reviewers:
DerekS, caryclark1, reed1
CC:
skia-review_googlegroups.com
Base URL:
http://skia.googlecode.com/svn/trunk/
Visibility:
Public.

Description

posix: Avoid static initializers in static/global mutexes This patch removes static initializers related to static and global mutexes from the final library's machine code when building on a pthread-capable system. We use PTHREAD_MUTEX_INITIALIZER to perform POD-style initialization. You need a line like the following to declare a global mutex with it: SkBaseMutex gMutex = { PTHREAD_MUTEX_INITIALIZER }; We introduce the SK_DECLARE_STATIC_MUTEX and SK_DECLARE_GLOBAL_MUTEX macros to be able to declare static/global mutexes in the source tree uniformly. SkMutex is now defined as a sub-class of SkBaseMutex, with standard construction/destruction semantics. This is useful if the mutex object is a member of another C++ class, or allocated dynamically. We also modify a few places to refer to SkBaseMutex instead of a SkMutex, where it makes sense. Generally speaking, client code should hold and use pointers to SkBaseMutex whenever they can now. We defined a new built-time macro named SK_USE_POSIX_THREADS to indicate that we're using a pthread-based SkThread.h interface. The macro will also be used in future patches to implement other helper thread synchronization classes. Finally, we inline the acquire() and release() functions in the case of Posix to improve performance a bit. Running: 'bench -repeat 10 -match mutex' on an Android device or a 2.4GHz Xeon Linux desktop shows the following improvements: Before After Galaxy Nexus 1.64 1.45 Nexus S 1.47 1.16 Xoom 1.86 1.66 Xeon 0.36 0.31 This removes 5 static mutex initializers from the library Committed: https://code.google.com/p/skia/source/detail?r=3091

Patch Set 1 #

Total comments: 1

Patch Set 2 : posix: Avoid static initializers in static/global mutexes #

Total comments: 12

Patch Set 3 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+120 lines, -41 lines) Patch
M bench/MutexBench.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M gyp/common_conditions.gypi View 1 2 1 chunk +8 lines, -0 lines 0 comments Download
M include/core/SkPixelRef.h View 1 2 2 chunks +4 lines, -4 lines 0 comments Download
M include/core/SkThread.h View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
M include/core/SkThread_platform.h View 1 2 2 chunks +45 lines, -2 lines 0 comments Download
M include/pdf/SkPDFFont.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M include/pdf/SkPDFGraphicState.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M include/pdf/SkPDFShader.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M obsolete/SkGLDevice.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkMemory_stdlib.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/core/SkPixelRef.cpp View 1 2 3 chunks +3 lines, -3 lines 0 comments Download
M src/core/SkTypefaceCache.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/effects/SkGradientShader.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/gpu/SkGrTexturePixelRef.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/images/SkImageRef.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/images/SkImageRef_GlobalPool.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/pdf/SkPDFFont.cpp View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M src/pdf/SkPDFGraphicState.cpp View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M src/pdf/SkPDFShader.cpp View 1 2 1 chunk +4 lines, -3 lines 0 comments Download
M src/ports/SkFontHost_FreeType.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkFontHost_android.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkFontHost_fontconfig.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkFontHost_linux.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkFontHost_mac_atsui.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkFontHost_mac_coretext.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkFontHost_simple.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkFontHost_win.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/ports/SkThread_pthread.cpp View 1 2 3 chunks +26 lines, -1 line 0 comments Download
M src/views/SkEventSink.cpp View 1 2 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 9
digit
this is the correct version, but previous notes still apply: 1/ Will slightly conflict with ...
12 years, 11 months ago (2011-12-22 17:26:32 UTC) #1
digit
http://codereview.appspot.com/5501066/diff/1/include/core/SkThread_platform.h File include/core/SkThread_platform.h (right): http://codereview.appspot.com/5501066/diff/1/include/core/SkThread_platform.h#newcode67 include/core/SkThread_platform.h:67: >>>>>>> ab852a0... posix: Avoid static initializers in static/global mutexes ...
12 years, 10 months ago (2012-01-10 10:40:49 UTC) #2
digit
On 2012/01/10 10:40:49, digit wrote: > http://codereview.appspot.com/5501066/diff/1/include/core/SkThread_platform.h > File include/core/SkThread_platform.h (right): > > http://codereview.appspot.com/5501066/diff/1/include/core/SkThread_platform.h#newcode67 > ...
12 years, 10 months ago (2012-01-11 18:02:59 UTC) #3
digit
ping?
12 years, 10 months ago (2012-01-19 13:58:10 UTC) #4
caryclark1
It looks like the !SK_USE_POSIX_THREADS case has not been compiled or tested. http://codereview.appspot.com/5501066/diff/3002/include/core/SkThread_platform.h File include/core/SkThread_platform.h ...
12 years, 10 months ago (2012-01-19 15:18:57 UTC) #5
digit
http://codereview.appspot.com/5501066/diff/3002/include/core/SkThread_platform.h File include/core/SkThread_platform.h (right): http://codereview.appspot.com/5501066/diff/3002/include/core/SkThread_platform.h#newcode109 include/core/SkThread_platform.h:109: class SkMutex : public SkBaseMutex { On 2012/01/19 15:18:57, ...
12 years, 10 months ago (2012-01-19 15:31:02 UTC) #6
digit
The third patch should answer Cary's remarks. Note that I did test the !SK_USE_POSIX_THREADS case ...
12 years, 10 months ago (2012-01-19 20:08:40 UTC) #7
digit
On 2012/01/19 20:08:40, digit wrote: > The third patch should answer Cary's remarks. Note that ...
12 years, 10 months ago (2012-01-26 20:47:08 UTC) #8
caryclark1
12 years, 10 months ago (2012-01-26 20:55:45 UTC) #9
LGTM
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b