Skip to content

Commit d5298ef

Browse files
committed
suggestions from review
1 parent 0b93e39 commit d5298ef

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

src/gc.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,16 +3957,13 @@ void jl_free_thread_gc_state(jl_ptls_t ptls)
39573957
arraylist_free(&mq->reclaim_set);
39583958
}
39593959

3960-
void jl_spawn_gc_threads(void)
3960+
void jl_start_gc_threads(void)
39613961
{
39623962
int nthreads = jl_atomic_load_relaxed(&jl_n_threads);
39633963
int ngcthreads = jl_n_gcthreads;
39643964
int nmutator_threads = nthreads - ngcthreads;
39653965
uv_thread_t uvtid;
3966-
for (int i = 1; i < nthreads; ++i) {
3967-
if (i < nmutator_threads) {
3968-
continue;
3969-
}
3966+
for (int i = nmutator_threads; i < nthreads; ++i) {
39703967
jl_threadarg_t *t = (jl_threadarg_t *)malloc_s(sizeof(jl_threadarg_t)); // ownership will be passed to the thread
39713968
t->tid = i;
39723969
t->barrier = &thread_init_done;

src/init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,8 @@ static NOINLINE void _finish_julia_init(JL_IMAGE_SEARCH rel, jl_ptls_t ptls, jl_
885885
post_image_load_hooks();
886886
}
887887
jl_start_threads();
888+
jl_start_gc_threads();
889+
uv_barrier_wait(&thread_init_done);
888890

889891
jl_gc_enable(1);
890892

src/julia_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ extern JL_DLLEXPORT ssize_t jl_tls_offset;
960960
extern JL_DLLEXPORT const int jl_tls_elf_support;
961961
void jl_init_threading(void);
962962
void jl_start_threads(void);
963-
void jl_spawn_gc_threads(void);
963+
void jl_start_gc_threads(void);
964964

965965
// Whether the GC is running
966966
extern uv_mutex_t safepoint_lock;

src/threading.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -802,23 +802,18 @@ void jl_start_threads(void)
802802
// GC/System threads need to be after the worker threads.
803803
int nmutator_threads = nthreads - ngcthreads;
804804

805-
for (i = 1; i < nthreads; ++i) {
806-
if (i < nmutator_threads) {
807-
jl_threadarg_t *t = (jl_threadarg_t *)malloc_s(sizeof(jl_threadarg_t)); // ownership will be passed to the thread
808-
t->tid = i;
809-
t->barrier = &thread_init_done;
810-
uv_thread_create(&uvtid, jl_threadfun, t);
811-
if (exclusive) {
812-
mask[i] = 1;
813-
uv_thread_setaffinity(&uvtid, mask, NULL, cpumasksize);
814-
mask[i] = 0;
815-
}
805+
for (i = 1; i < nmutator_threads; ++i) {
806+
jl_threadarg_t *t = (jl_threadarg_t *)malloc_s(sizeof(jl_threadarg_t)); // ownership will be passed to the thread
807+
t->tid = i;
808+
t->barrier = &thread_init_done;
809+
uv_thread_create(&uvtid, jl_threadfun, t);
810+
if (exclusive) {
811+
mask[i] = 1;
812+
uv_thread_setaffinity(&uvtid, mask, NULL, cpumasksize);
813+
mask[i] = 0;
816814
}
817815
uv_thread_detach(&uvtid);
818816
}
819-
jl_spawn_gc_threads();
820-
821-
uv_barrier_wait(&thread_init_done);
822817
}
823818

824819
_Atomic(unsigned) _threadedregion; // keep track of whether to prioritize IO or threading

src/threading.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ extern "C" {
1212

1313
#define PROFILE_JL_THREADING 0
1414

15+
extern uv_barrier_t thread_init_done;
16+
1517
extern _Atomic(jl_ptls_t*) jl_all_tls_states JL_GLOBALLY_ROOTED; /* thread local storage */
1618

1719
typedef struct _jl_threadarg_t {

0 commit comments

Comments
 (0)