Skip to content

Commit 2f42cd5

Browse files
committed
Relax some of the atomics for sweeping
1 parent 5f36833 commit 2f42cd5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/gc.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,10 @@ static bigval_t **sweep_big_list(int sweep_full, bigval_t **pv) JL_NOTSAFEPOINT
10571057
if (nxt)
10581058
nxt->prev = pv;
10591059
gc_num.freed += v->sz&~3;
1060-
jl_atomic_fetch_add_relaxed(&gc_heap_stats.malloc_bytes_freed, v->sz&~3);
1061-
jl_atomic_fetch_add_relaxed(&gc_heap_stats.heap_size, -(v->sz&~3));
1060+
jl_atomic_store_relaxed(&gc_heap_stats.malloc_bytes_freed,
1061+
jl_atomic_load_relaxed(&gc_heap_stats.malloc_bytes_freed) + (v->sz&~3));
1062+
jl_atomic_store_relaxed(&gc_heap_stats.heap_size,
1063+
jl_atomic_load_relaxed(&gc_heap_stats.heap_size) - (v->sz&~3));
10621064
#ifdef MEMDEBUG
10631065
memset(v, 0xbb, v->sz&~3);
10641066
#endif
@@ -1194,6 +1196,10 @@ static void jl_gc_free_array(jl_array_t *a) JL_NOTSAFEPOINT
11941196
jl_free_aligned(d);
11951197
else
11961198
free(d);
1199+
jl_atomic_store_relaxed(&gc_heap_stats.malloc_bytes_freed,
1200+
jl_atomic_load_relaxed(&gc_heap_stats.malloc_bytes_freed) + jl_array_nbytes(a));
1201+
jl_atomic_store_relaxed(&gc_heap_stats.heap_size,
1202+
jl_atomic_load_relaxed(&gc_heap_stats.heap_size) - jl_array_nbytes(a));
11971203
jl_atomic_fetch_add_relaxed(&gc_heap_stats.malloc_bytes_freed, jl_array_nbytes(a));
11981204
jl_atomic_fetch_add_relaxed(&gc_heap_stats.heap_size, -jl_array_nbytes(a));
11991205
gc_num.freed += jl_array_nbytes(a);

test/testenv.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ if !@isdefined(testenv_defined)
3737

3838
function addprocs_with_testenv(X; rr_allowed=true, kwargs...)
3939
exename = rr_allowed ? `$rr_exename $test_exename` : test_exename
40+
if X isa Integer
41+
if Sys.iswindows()
42+
heap_size=round(Int,(Sys.free_memory()/(1024^2)/(X+1)))
43+
heap_size -= 300 # I don't know anymore
44+
else
45+
heap_size=round(Int,(Sys.total_memory()/(1024^2)/(X+1)))
46+
end
47+
push!(test_exeflags.exec, "--heap-size-hint=$(heap_size)M")
48+
end
4049
addprocs(X; exename=exename, exeflags=test_exeflags, kwargs...)
4150
end
4251

0 commit comments

Comments
 (0)