Skip to content

Commit

Permalink
Merge pull request eclipse-openj9#18646 from amicic/gcmaxthreads
Browse files Browse the repository at this point in the history
Set gcThreadCountSpecified and allow -Xgcmaxthreads for restore VM
  • Loading branch information
dmitripivkine authored Dec 18, 2023
2 parents 2954ed7 + 6497a92 commit 316f2a9
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 316f2a9

Please sign in to comment.