Skip to content

Commit 70b5ecc

Browse files
committed
added a few suggestions from Yi's review
1 parent 19eac4f commit 70b5ecc

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/gc-stock.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,7 +3212,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
32123212
uint64_t target_heap;
32133213
const char *reason = ""; (void)reason; // for GC_TIME output stats
32143214
old_heap_size = heap_size; // TODO: Update these values dynamically instead of just during the GC
3215-
if (collection == JL_GC_AUTO) {
3215+
if (collection == JL_GC_AUTO && jl_options.hard_heap_limit == UINT64_MAX) {
32163216
// update any heuristics only when the user does not force the GC
32173217
// but still update the timings, since GC was run and reset, even if it was too early
32183218
uint64_t target_allocs = 0.0;
@@ -3301,21 +3301,12 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
33013301
heap_size, jl_options.hard_heap_limit);
33023302
}
33033303
// Ignore heap limit computation from MemBalancer-like heuristics
3304-
// if the user has set a `--hard-heap-limit` through the command line.
3305-
// Note that if we reach this code, we can guarantee that the heap size
3306-
// is less than the hard limit, so there will be some room to grow the heap
3307-
// until the next GC without hitting the hard limit.
3308-
if (jl_options.hard_heap_limit != UINT64_MAX) {
3309-
jl_atomic_store_relaxed(&gc_heap_stats.heap_target, jl_options.hard_heap_limit);
3310-
target_heap = jl_options.hard_heap_limit;
3311-
}
3312-
// Ignore heap limit computation from MemBalancer-like heuristics
33133304
// if the heap target increment goes above the value specified through
33143305
// `--upper-bound-for-heap-target-increment`.
33153306
// Note that if we reach this code, we can guarantee that the heap size
33163307
// is less than the hard limit, so there will be some room to grow the heap
33173308
// until the next GC without hitting the hard limit.
3318-
if (target_heap - heap_size > jl_options.upper_bound_for_heap_target_increment) {
3309+
if (jl_options.upper_bound_for_heap_target_increment != UINT64_MAX) {
33193310
target_heap = heap_size + jl_options.upper_bound_for_heap_target_increment;
33203311
jl_atomic_store_relaxed(&gc_heap_stats.heap_target, target_heap);
33213312
}
@@ -3718,6 +3709,9 @@ void jl_gc_init(void)
37183709
arraylist_new(&finalizer_list_marked, 0);
37193710
arraylist_new(&to_finalize, 0);
37203711
jl_atomic_store_relaxed(&gc_heap_stats.heap_target, default_collect_interval);
3712+
if (jl_options.hard_heap_limit != UINT64_MAX) {
3713+
jl_atomic_store_relaxed(&gc_heap_stats.heap_target, jl_options.hard_heap_limit);
3714+
}
37213715
gc_num.interval = default_collect_interval;
37223716
gc_num.allocd = 0;
37233717
gc_num.max_pause = 0;

src/jloptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,13 +988,13 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
988988
case opt_hard_heap_limit:
989989
if (optarg != NULL)
990990
jl_options.hard_heap_limit = parse_heap_size_option(optarg, "--hard-heap-limit=<size>[<unit>]");
991-
if (jl_options.hard_heap_limit == 0)
991+
if (jl_options.hard_heap_limit == 0 || jl_options.hard_heap_limit == UINT64_MAX) // UINT64_MAX is a special value for "no limit specified"
992992
jl_errorf("julia: invalid memory size specified in --hard-heap-limit=<size>[<unit>]");
993993
break;
994994
case opt_upper_bound_for_heap_target_increment:
995995
if (optarg != NULL)
996996
jl_options.upper_bound_for_heap_target_increment = parse_heap_size_option(optarg, "--upper-bound-for-heap-target-increment=<size>[<unit>]");
997-
if (jl_options.upper_bound_for_heap_target_increment == 0)
997+
if (jl_options.upper_bound_for_heap_target_increment == 0 || jl_options.upper_bound_for_heap_target_increment == UINT64_MAX) // UINT64_MAX is a special value for "no limit specified"
998998
jl_errorf("julia: invalid memory size specified in --upper-bound-for-heap-target-increment=<size>[<unit>]");
999999
break;
10001000
#endif

0 commit comments

Comments
 (0)