vp8 : use threading mutex's for tsan only.
To avoid decode performance hit of 2% when running on hyperthreaded cores. This patch only uses the mutex's when we are running tsan. This is safe because 32 bit operations like read and store are atomic on all the platforms we care about. Tsan warns about race situations, but in this case either situation ( read occurs before write or write before read) the worst case is that we go around one extra time in the loop. So the ordering doesn't really matter. That said a few other things have been tried : for instance as per here: webrtc/base/atomicops.h#52 In this patch they use: __atomic_load_n(i, __ATOMIC_ACQUIRE); __atomic_store_n(i, value, __ATOMIC_RELEASE); This code works on gcc, clang ( replacing protected write and read), and avoids tsan errors. Incurring no penalty in performance. In C11 its replaced by straight atomic operands. However there is no equivalent in the visual studio's we support as int32 on all windows platforms is already atomic. To avoid tsan like warnings on windows we'd need to use interlocked exchange and the end result doesn't gain us any thing. Change-Id: I2066e3c7f42641ebb23d53feb1f16f23f85bcf59
Showing with 18 additions and 17 deletions