Skip to content

Commit 5bb4714

Browse files
authored
Merge pull request #54 from udesou/feature/stock-gc-trigger
Using Julia's stock GC trigger/heuristics as default
2 parents 03f5493 + 84224df commit 5bb4714

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/mmtk-gc.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ void jl_gc_init(void)
381381
char* max_size_def = getenv("MMTK_MAX_HSIZE");
382382
char* max_size_gb = getenv("MMTK_MAX_HSIZE_G");
383383

384-
// default min heap currently set as Julia's default_collect_interval
384+
// default min heap currently set as 0
385+
// and default max heap currently set as 0
386+
// which means that by default mmtk will use stock heuristics
385387
if (min_size_def != NULL) {
386388
char *p;
387389
double min_size = strtod(min_size_def, &p);
@@ -391,10 +393,9 @@ void jl_gc_init(void)
391393
double min_size = strtod(min_size_gb, &p);
392394
min_heap_size = (long) 1024 * 1024 * 1024 * min_size;
393395
} else {
394-
min_heap_size = (long) 1024 * 1024 * 1024 * 1;
396+
min_heap_size = 0;
395397
}
396398

397-
// default max heap currently set as 30 Gb
398399
if (max_size_def != NULL) {
399400
char *p;
400401
double max_size = strtod(max_size_def, &p);
@@ -404,7 +405,7 @@ void jl_gc_init(void)
404405
double max_size = strtod(max_size_gb, &p);
405406
max_heap_size = (long) 1024 * 1024 * 1024 * max_size;
406407
} else {
407-
max_heap_size = (long) uv_get_free_memory() * 60 / 100;
408+
max_heap_size = 0;
408409
}
409410

410411
// Assert that the number of stock GC threads is 0; MMTK uses the number of threads in jl_options.ngcthreads
@@ -425,11 +426,11 @@ void jl_gc_init(void)
425426
// TODO: We just assume mark threads means GC threads, and ignore the number of concurrent sweep threads.
426427
// If the two values are the same, we can use either. Otherwise, we need to be careful.
427428
uintptr_t gcthreads = jl_options.ngcthreads;
428-
if (max_size_def != NULL || (max_size_gb != NULL && (min_size_def == NULL && min_size_gb == NULL))) {
429-
mmtk_gc_init(0, max_heap_size, gcthreads, &mmtk_upcalls, (sizeof(jl_taggedvalue_t)), jl_buff_tag);
430-
} else {
431-
mmtk_gc_init(min_heap_size, max_heap_size, gcthreads, &mmtk_upcalls, (sizeof(jl_taggedvalue_t)), jl_buff_tag);
432-
}
429+
// if only max_heap_size is set (max_size_def != 0), mmtk will run with a fixed heap size
430+
// if both min_heap_size and max_heap_size are set (their values different than 0), mmtk will use membalancer
431+
// and resize the heap within those values. If none of these variables are set, then mmtk will use stock heuristics
432+
// note that this will be overwritten in Rust by the env variable MMTK_GC_TRIGGER
433+
mmtk_gc_init(min_heap_size, max_heap_size, gcthreads, &mmtk_upcalls, (sizeof(jl_taggedvalue_t)), jl_buff_tag);
433434
}
434435

435436
// allocation wrappers that track allocation and let collection run

0 commit comments

Comments
 (0)