Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Julia's stock GC trigger/heuristics as default #54

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/mmtk-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ void jl_gc_init(void)
char* max_size_def = getenv("MMTK_MAX_HSIZE");
char* max_size_gb = getenv("MMTK_MAX_HSIZE_G");

// default min heap currently set as Julia's default_collect_interval
// default min heap currently set as 0
// and default max heap currently set as 0
// which means that by default mmtk will use stock heuristics
if (min_size_def != NULL) {
char *p;
double min_size = strtod(min_size_def, &p);
Expand All @@ -391,10 +393,9 @@ void jl_gc_init(void)
double min_size = strtod(min_size_gb, &p);
min_heap_size = (long) 1024 * 1024 * 1024 * min_size;
} else {
min_heap_size = (long) 1024 * 1024 * 1024 * 1;
min_heap_size = 0;
}

// default max heap currently set as 30 Gb
if (max_size_def != NULL) {
char *p;
double max_size = strtod(max_size_def, &p);
Expand All @@ -404,7 +405,7 @@ void jl_gc_init(void)
double max_size = strtod(max_size_gb, &p);
max_heap_size = (long) 1024 * 1024 * 1024 * max_size;
} else {
max_heap_size = (long) uv_get_free_memory() * 60 / 100;
max_heap_size = 0;
}

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

// allocation wrappers that track allocation and let collection run
Expand Down