Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance regression in Qthreads 1.21 #309

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion include/qt_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,24 @@
#define THREAD_FENCE_MEM_RELEASE THREAD_FENCE_MEM_RELEASE_IMPL
#endif

#if QTHREAD_ASSEMBLY_ARCH == QTHREAD_IA32 || \
QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64
#define SPINLOCK_BODY() \
do { MACHINE_FENCE; } while (0)
do { __asm__ __volatile__("pause" ::: "memory"); } while (0)
#elif QTHREAD_ASSEMBLY_ARCH == QTHREAD_ARM || \
QTHREAD_ASSEMBLY_ARCH == QTHREAD_ARMV8_A64
#define SPINLOCK_BODY() \
do { __asm__ __volatile__("yield" ::: "memory"); } while (0)
#elif QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC64 || \
QTHREAD_ASSEMBLY_ARCH == QTHREAD_POWERPC32
// For whatever reason the 29 (mdoio) version of this instruction performed
// better in some back-of-the-envelope benchmarking so we're using that.
#define SPINLOCK_BODY() \
do { __asm__ __volatile__("or 29,29,29" ::: "memory"); } while (0)
#else
#define SPINLOCK_BODY() \
do { atomic_thread_fence(memory_order_acq_rel); } while (0)
#endif

#define QTHREAD_FASTLOCK_SETUP() \
do { \
Expand Down
Loading