Skip to content

Commit

Permalink
Backport More Qthreads Performance Fixes (#26328)
Browse files Browse the repository at this point in the history
Backporting two more performance fixes from
sandialabs/qthreads#314.

[Contributed by @insertinterestingnamehere. Reviewed and merged by @jabraham17]
  • Loading branch information
jabraham17 authored Dec 12, 2024
2 parents 3a79d12 + 90785f2 commit c93e20f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
30 changes: 29 additions & 1 deletion third-party/qthread/README
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ index 8269aa0949..bf022bc243 100644

```

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

```
diff --git a/include/qt_atomics.h b/include/qt_atomics.h
Expand Down Expand Up @@ -87,3 +88,30 @@ index 2ac887ed..2312c954 100644
#define QTHREAD_FASTLOCK_SETUP() \
do { \
```

```
--- a/src/io.c
+++ b/src/io.c
@@ -74,7 +74,6 @@ static void qt_blocking_subsystem_internal_freemem(void) { /*{{{*/
static void *qt_blocking_subsystem_proxy_thread(void *Q_UNUSED(arg)) { /*{{{*/
while (!atomic_load_explicit(&proxy_exit, memory_order_relaxed)) {
if (qt_process_blocking_call()) { break; }
- MACHINE_FENCE;
}
atomic_fetch_sub_explicit(&io_worker_count, 1, memory_order_relaxed);
pthread_exit(NULL);
```

```
--- a/include/qthread/qthread.h
+++ b/include/qthread/qthread.h
@@ -87,7 +87,7 @@ using std::memory_order_relaxed;

#include "macros.h"

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

#if QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64
#define QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
```
2 changes: 1 addition & 1 deletion third-party/qthread/qthread-src/include/qthread/qthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ using std::memory_order_relaxed;

#include "macros.h"

#define MACHINE_FENCE atomic_thread_fence(memory_order_acq_rel);
#define MACHINE_FENCE atomic_thread_fence(memory_order_seq_cst);

#if QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64
#define QTHREAD_SWAPS_IMPLY_ACQ_REL_FENCES
Expand Down
1 change: 0 additions & 1 deletion third-party/qthread/qthread-src/src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ static void qt_blocking_subsystem_internal_freemem(void) { /*{{{*/
static void *qt_blocking_subsystem_proxy_thread(void *Q_UNUSED(arg)) { /*{{{*/
while (!atomic_load_explicit(&proxy_exit, memory_order_relaxed)) {
if (qt_process_blocking_call()) { break; }
MACHINE_FENCE;
}
atomic_fetch_sub_explicit(&io_worker_count, 1, memory_order_relaxed);
pthread_exit(NULL);
Expand Down

0 comments on commit c93e20f

Please sign in to comment.