Skip to content

Commit

Permalink
Set gcThreadCountSpecified and allow -Xgcmaxthreads for restore VM
Browse files Browse the repository at this point in the history
Set gcThreadCountSpecified if either -Xgcthreads or -Xgcmaxthreads is
specified, and use gcThreadCountForced to distinguish between the 2
options. This is a part of the fix that will allow -Xgcmaxthreads to
work as expected (another OMR change is needed to make use of now
properly set gcThreadCountSpecified flag).

Aslo, allow -Xgcmaxthreads to be specified on restore VM too, and make
sure that whichever is the last one wins (in any combination of those 2
options being or not beign specified on snapshot or restore side).
Parsing of -Xgcmaxthreads handles it, since it's the latter one that
gets processed in the code.

There is also a change in behavior for restore VM. Previosly, if
-Xgcthreads was specified on snapshot side, it would be ignored on
restore side and the thread count would be recalculated from scratch.
Now, if that option (or gcmaxthreads variant) is specified on snapshot
side it will obeyed on restore side. Of course if restore side specifies
any of the 2 options that will override the snapshot value. That was
true before and still true, except that the value will possible to
override by either gcthreads or (once fully working) gcmaxthreads
variant.

Signed-off-by: Aleksandar Micic <[email protected]>
  • Loading branch information
Aleksandar Micic authored and Aleksandar Micic committed Dec 18, 2023
1 parent 22eb305 commit 6497a92
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
7 changes: 6 additions & 1 deletion runtime/gc_modron_startup/mminit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,12 @@ gcReinitializeDefaultsForRestore(J9VMThread* vmThread)
PORT_ACCESS_FROM_JAVAVM(vm);
OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);

extensions->gcThreadCountForced = false;
/* If Snapshot VM did not specify -Xgcthreads or -Xgcmaxthreads, the count will be determined from scratch, either as new restore default or through restore specified options.
* If Snapshot VM did specify, we want to continue using the count value unless (only) restore specific options override it */
if (!extensions->gcThreadCountSpecified) {
extensions->gcThreadCount = 0;
extensions->gcThreadCountForced = false;
}
extensions->parSweepChunkSize = 0;

if (!gcParseReconfigurableCommandLine(vm, vm->checkpointState.restoreArgsList)) {
Expand Down
50 changes: 30 additions & 20 deletions runtime/gc_modron_startup/mmparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,26 +981,6 @@ gcParseSovereignArguments(J9JavaVM *vm)
extensions->heapContractionGCRatioThreshold._wasSpecified = true;
}

/* Handling VMOPT_XGCMAXTHREADS is equivalent to VMOPT_XGCTHREADS (above), except it sets gcThreadCountForced to false rather than true. */
if (-1 != FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, VMOPT_XGCMAXTHREADS, NULL)) {
result = option_set_to_opt_integer(vm, VMOPT_XGCMAXTHREADS, &index, EXACT_MEMORY_MATCH, &extensions->gcThreadCount);
if (OPTION_OK != result) {
if (OPTION_MALFORMED == result) {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_MUST_BE_NUMBER, VMOPT_XGCMAXTHREADS);
} else {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_OVERFLOWED, VMOPT_XGCMAXTHREADS);
}
goto _error;
}

if (0 == extensions->gcThreadCount) {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_MUST_BE_ABOVE, VMOPT_XGCMAXTHREADS, (UDATA)0);
goto _error;
}

extensions->gcThreadCountForced = false;
}

if(-1 != FIND_ARG_IN_VMARGS(EXACT_MEMORY_MATCH, "-Xgcworkpackets", NULL)) {
result = option_set_to_opt_integer(vm, "-Xgcworkpackets", &index, EXACT_MEMORY_MATCH, &extensions->workpacketCount);
if (OPTION_OK != result) {
Expand Down Expand Up @@ -1275,11 +1255,13 @@ gcParseReconfigurableSoverignArguments(J9JavaVM* vm, J9VMInitArgs* args)
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(vm);
IDATA index = -1;
IDATA result = 0;
IDATA gcthread_index = -1;

PORT_ACCESS_FROM_JAVAVM(vm);

if (-1 != FIND_ARG_IN_ARGS(args, EXACT_MEMORY_MATCH, VMOPT_XGCTHREADS, NULL)) {
result = option_set_to_opt_integer_args(vm, VMOPT_XGCTHREADS, &index, EXACT_MEMORY_MATCH, &extensions->gcThreadCount, args);
gcthread_index = index;
if (OPTION_OK != result) {
if (OPTION_MALFORMED == result) {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_MUST_BE_NUMBER, VMOPT_XGCTHREADS);
Expand All @@ -1294,9 +1276,37 @@ gcParseReconfigurableSoverignArguments(J9JavaVM* vm, J9VMInitArgs* args)
goto _error;
}

extensions->gcThreadCountSpecified = true;
extensions->gcThreadCountForced = true;
}

/* Handling VMOPT_XGCMAXTHREADS is equivalent to VMOPT_XGCTHREADS (above), except it sets gcThreadCountForced to false rather than true. */
if (-1 != FIND_ARG_IN_ARGS(args, EXACT_MEMORY_MATCH, VMOPT_XGCMAXTHREADS, NULL)) {
UDATA gcThreadCount = 0;
IDATA gcmaxthread_index = -1;

result = option_set_to_opt_integer_args(vm, VMOPT_XGCMAXTHREADS, &gcmaxthread_index, EXACT_MEMORY_MATCH, &gcThreadCount, args);
if (OPTION_OK != result) {
if (OPTION_MALFORMED == result) {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_MUST_BE_NUMBER, VMOPT_XGCMAXTHREADS);
} else {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_OVERFLOWED, VMOPT_XGCMAXTHREADS);
}
goto _error;
}

if (0 == gcThreadCount) {
j9nls_printf(PORTLIB, J9NLS_ERROR, J9NLS_GC_OPTIONS_VALUE_MUST_BE_ABOVE, VMOPT_XGCMAXTHREADS, (UDATA)0);
goto _error;
}

if (gcmaxthread_index > gcthread_index) {
extensions->gcThreadCount = gcThreadCount;
extensions->gcThreadCountSpecified = true;
extensions->gcThreadCountForced = false;
}
}

return true;

_error:
Expand Down
2 changes: 2 additions & 0 deletions runtime/gc_modron_startup/mmparseXgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ j9gc_initialize_parse_gc_colon(J9JavaVM *javaVM, char **scan_start)
goto _error;
}

extensions->gcThreadCountSpecified = true;
extensions->gcThreadCountForced = true;
goto _exit;
}
Expand Down Expand Up @@ -233,6 +234,7 @@ j9gc_initialize_parse_gc_colon(J9JavaVM *javaVM, char **scan_start)
goto _error;
}

extensions->gcThreadCountSpecified = true;
extensions->gcThreadCountForced = true;
goto _exit;
}
Expand Down

0 comments on commit 6497a92

Please sign in to comment.