Skip to content

Commit c93e20f

Browse files
authored
Backport More Qthreads Performance Fixes (#26328)
Backporting two more performance fixes from sandialabs/qthreads#314. [Contributed by @insertinterestingnamehere. Reviewed and merged by @jabraham17]
2 parents 3a79d12 + 90785f2 commit c93e20f

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

third-party/qthread/README

+29-1
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ index 8269aa0949..bf022bc243 100644
5252

5353
```
5454

55-
* Backport a performance fix from the development version of qthreads.
55+
* Backport a few performance fixes from the development version of qthreads.
5656
https://github.com/chapel-lang/chapel/pull/26138
57+
https://github.com/chapel-lang/chapel/pull/26328
5758

5859
```
5960
diff --git a/include/qt_atomics.h b/include/qt_atomics.h
@@ -87,3 +88,30 @@ index 2ac887ed..2312c954 100644
8788
#define QTHREAD_FASTLOCK_SETUP() \
8889
do { \
8990
```
91+
92+
```
93+
--- a/src/io.c
94+
+++ b/src/io.c
95+
@@ -74,7 +74,6 @@ static void qt_blocking_subsystem_internal_freemem(void) { /*{{{*/
96+
static void *qt_blocking_subsystem_proxy_thread(void *Q_UNUSED(arg)) { /*{{{*/
97+
while (!atomic_load_explicit(&proxy_exit, memory_order_relaxed)) {
98+
if (qt_process_blocking_call()) { break; }
99+
- MACHINE_FENCE;
100+
}
101+
atomic_fetch_sub_explicit(&io_worker_count, 1, memory_order_relaxed);
102+
pthread_exit(NULL);
103+
```
104+
105+
```
106+
--- a/include/qthread/qthread.h
107+
+++ b/include/qthread/qthread.h
108+
@@ -87,7 +87,7 @@ using std::memory_order_relaxed;
109+
110+
#include "macros.h"
111+
112+
-#define MACHINE_FENCE atomic_thread_fence(memory_order_acq_rel);
113+
+#define MACHINE_FENCE atomic_thread_fence(memory_order_seq_cst);
114+
115+
#if QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64
116+
#define QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
117+
```

third-party/qthread/qthread-src/include/qthread/qthread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ using std::memory_order_relaxed;
8787

8888
#include "macros.h"
8989

90-
#define MACHINE_FENCE atomic_thread_fence(memory_order_acq_rel);
90+
#define MACHINE_FENCE atomic_thread_fence(memory_order_seq_cst);
9191

9292
#if QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64
9393
#define QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES

third-party/qthread/qthread-src/src/io.c

-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ static void qt_blocking_subsystem_internal_freemem(void) { /*{{{*/
7474
static void *qt_blocking_subsystem_proxy_thread(void *Q_UNUSED(arg)) { /*{{{*/
7575
while (!atomic_load_explicit(&proxy_exit, memory_order_relaxed)) {
7676
if (qt_process_blocking_call()) { break; }
77-
MACHINE_FENCE;
7877
}
7978
atomic_fetch_sub_explicit(&io_worker_count, 1, memory_order_relaxed);
8079
pthread_exit(NULL);

0 commit comments

Comments
 (0)