Skip to content

Commit

Permalink
Bug fix for max_collect_interval computation (#45727)
Browse files Browse the repository at this point in the history
Currently constrained to `totalmem / ncores / 2` for `_P64` which
results in a very short collect interval when you're running with
a smaller number of threads on a machine with many cores.

Changes this to `totalmem / nthreads / 2` which, for two of our
tests, resulted in 40% and 60% runtime reduction (!!) as well as
GC time reduction from 46% to 10% and 64% to 11%.
  • Loading branch information
kpamnany authored Jun 21, 2022
1 parent 58b351f commit c4c36ed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3447,12 +3447,12 @@ void jl_gc_init(void)
gc_num.max_memory = 0;

#ifdef _P64
// on a big memory machine, set max_collect_interval to totalmem / ncores / 2
// on a big memory machine, set max_collect_interval to totalmem / nthreads / 2
uint64_t total_mem = uv_get_total_memory();
uint64_t constrained_mem = uv_get_constrained_memory();
if (constrained_mem > 0 && constrained_mem < total_mem)
total_mem = constrained_mem;
size_t maxmem = total_mem / jl_cpu_threads() / 2;
size_t maxmem = total_mem / jl_n_threads / 2;
if (maxmem > max_collect_interval)
max_collect_interval = maxmem;
#endif
Expand Down

0 comments on commit c4c36ed

Please sign in to comment.