diff options
author | nineonine <mail4chemik@gmail.com> | 2022-12-19 14:24:00 -0800 |
---|---|---|
committer | nineonine <mail4chemik@gmail.com> | 2022-12-19 14:24:00 -0800 |
commit | 681d39e44756c96fb052f6cae5091165c4ad4778 (patch) | |
tree | ef4dcd868f97fee1b5378e1a0fb7ace47c82ace7 | |
parent | b394041d5ddae7587d039598319d02932168f9c8 (diff) | |
download | haskell-wip/T19626.tar.gz |
Some Heap flagswip/T19626
-rw-r--r-- | rts/OptParse.c | 120 | ||||
-rw-r--r-- | rts/include/rts/OptParse.h | 2 | ||||
-rw-r--r-- | testsuite/tests/rts/OptParse/OptParseTest.c | 3 | ||||
-rw-r--r-- | testsuite/tests/rts/OptParse/OptParseTest.stderr | 156 | ||||
-rw-r--r-- | testsuite/tests/rts/OptParse/OptParseTest.stdout | 96 |
5 files changed, 323 insertions, 54 deletions
diff --git a/rts/OptParse.c b/rts/OptParse.c index b85fac50b9..561f03e60d 100644 --- a/rts/OptParse.c +++ b/rts/OptParse.c @@ -44,66 +44,69 @@ RtsFlagName rtsFlags[] = { - [HELP] = {SAFE, VOID, "help", "?" , false}, - [INSTALL_SIGNAL_HANDLERS] = {UNSAFE, BOOL, "install-signal-handlers", NULL, false}, - [INSTALL_SEH_HANDLERS] = {UNSAFE, BOOL, "install-seh-handlers", NULL, false}, - [GENERATE_STACK_TRACES] = {UNSAFE, BOOL, "generate-stack-traces", NULL, false}, - [GENERATE_CRASH_DUMPS] = {UNSAFE, BOOL, "generate-crash-dumps", NULL, false}, - [NULL_EVENTLOG_WRITER] = {UNSAFE, BOOL, "null-eventlog-writer", NULL, false}, - [MACHINE_READABLE] = {UNSAFE, BOOL, "machine-readable", NULL, false}, - [DISABLE_OS_MEM_RET] = {UNSAFE, BOOL, "disable-delayed-os-memory-return", NULL, false}, - [INTERNAL_COUNTERS] = {SAFE, BOOL, "internal-counters", NULL, false}, - [IO_MANAGER_FLAG] = {UNSAFE, ENUM, "io-manager", NULL, true}, - [INFO] = {SAFE, VOID, "info", NULL, false}, - [EVENTLOG_FLUSH_INTERVAL] = {SAFE, DOUBLE, "eventlog-flush-interval", NULL, true}, - [COPYING_GC] = {SAFE, VOID, "copying-gc", NULL, false}, - [NONMOVING_GC] = {SAFE, VOID, "nonmoving-gc", NULL, false}, - [LARGE_OBJ_ALLOC_AREA] = {UNSAFE, STGWORD64, "large-object-allocation", "AL", true}, - [MIN_ALLOC_AREA] = {UNSAFE, STGWORD64, "minimum-allocation-area-size", "A", true}, + [HELP] = {SAFE, VOID, "help", "?" , false}, + [INSTALL_SIGNAL_HANDLERS] = {UNSAFE, BOOL, "install-signal-handlers", NULL, false}, + [INSTALL_SEH_HANDLERS] = {UNSAFE, BOOL, "install-seh-handlers", NULL, false}, + [GENERATE_STACK_TRACES] = {UNSAFE, BOOL, "generate-stack-traces", NULL, false}, + [GENERATE_CRASH_DUMPS] = {UNSAFE, BOOL, "generate-crash-dumps", NULL, false}, + [NULL_EVENTLOG_WRITER] = {UNSAFE, BOOL, "null-eventlog-writer", NULL, false}, + [MACHINE_READABLE] = {UNSAFE, BOOL, "machine-readable", NULL, false}, + [DISABLE_OS_MEM_RET] = {UNSAFE, BOOL, "disable-delayed-os-memory-return", NULL, false}, + [INTERNAL_COUNTERS] = {SAFE, BOOL, "internal-counters", NULL, false}, + [IO_MANAGER_FLAG] = {UNSAFE, ENUM, "io-manager", NULL, true}, + [INFO] = {SAFE, VOID, "info", NULL, false}, + [EVENTLOG_FLUSH_INTERVAL] = {SAFE, DOUBLE, "eventlog-flush-interval", NULL, true}, + [COPYING_GC] = {SAFE, VOID, "copying-gc", NULL, false}, + [NONMOVING_GC] = {SAFE, VOID, "nonmoving-gc", NULL, false}, + [LARGE_OBJ_ALLOC_AREA] = {UNSAFE, STGWORD64, "large-object-allocation", "AL", true}, + [MIN_ALLOC_AREA] = {UNSAFE, STGWORD64, "minimum-allocation-area-size", "A", true}, // #if defined(THREADED_RTS) // #if defined(mingw32_HOST_OS) - [IO_MANAGER_THREADS] = {UNSAFE, STGWORD64, "io-manager-threads", NULL, true}, + [IO_MANAGER_THREADS] = {UNSAFE, STGWORD64, "io-manager-threads", NULL, true}, // #endif - [NUMA] = {SAFE, STGWORD64, "numa", NULL, false}, + [NUMA] = {SAFE, STGWORD64, "numa", NULL, false}, // #endif // #if defined(DEBUG) && defined(THREADED_RTS) - [DEBUG_NUMA] = {SAFE, STGWORD64, "debug-numa", NULL, true}, + [DEBUG_NUMA] = {SAFE, STGWORD64, "debug-numa", NULL, true}, // #endif - [LONG_GC_SYNC] = {SAFE, DOUBLE, "long-gc-sync", NULL, true}, - [NO_AUTO_HEAP_SAMPLES] = {UNSAFE, BOOL, "no-automatic-heap-samples", NULL, false}, - [NURSERY_CHUNK_SIZE] = {UNSAFE, STGWORD64, "alloc-area-chunksize", "n", true}, - [GC_BELL] = {UNSAFE, VOID, "gc-bell", "B", false}, - [COMPACT_GC] = {UNSAFE, DOUBLE, "compact-gc", "c", false}, - [USE_MARK_REGION] = {UNSAFE, VOID, "use-mark-region", "w", false}, - [OLD_GEN_FACTOR] = {UNSAFE, DOUBLE, "old-gen-factor", "F", true}, - [RETURN_DECAY_FACTOR] = {UNSAFE, DOUBLE, "return-decay-factor", "Fd", true}, + [LONG_GC_SYNC] = {SAFE, DOUBLE, "long-gc-sync", NULL, true}, + [NO_AUTO_HEAP_SAMPLES] = {UNSAFE, BOOL, "no-automatic-heap-samples", NULL, false}, + [NURSERY_CHUNK_SIZE] = {UNSAFE, STGWORD64, "alloc-area-chunksize", "n", true}, + [GC_BELL] = {UNSAFE, VOID, "gc-bell", "B", false}, + [COMPACT_GC] = {UNSAFE, DOUBLE, "compact-gc", "c", false}, + [USE_MARK_REGION] = {UNSAFE, VOID, "use-mark-region", "w", false}, + [OLD_GEN_FACTOR] = {UNSAFE, DOUBLE, "old-gen-factor", "F", true}, + [RETURN_DECAY_FACTOR] = {UNSAFE, DOUBLE, "return-decay-factor", "Fd", true}, // #if defined(DEBUG) - [DEBUG_SCHEDULER] = {SAFE, VOID, "debug-scheduler", "Ds", false}, - [DEBUG_INTERPRETER] = {SAFE, VOID, "debug-interpreter", "Di", false}, - [DEBUG_WEAK] = {SAFE, VOID, "debug-weak", "Dw", false}, - [DEBUG_GCCAFS] = {SAFE, VOID, "debug-gccafs", "DG", false}, - [DEBUG_GC] = {SAFE, VOID, "debug-gc", "Dg", false}, - [DEBUG_NONMOVING_GC] = {SAFE, VOID, "debug-nonmoving-gc", "Dn", false}, - [DEBUG_BLOCK_ALLOC] = {SAFE, VOID, "debug-block-alloc", "Db", false}, - [DEBUG_SANITY] = {SAFE, VOID, "debug-sanity", "DS", false}, - [DEBUG_ZERO_IN_GC] = {SAFE, VOID, "debug-zero-on-gc", "DZ", false}, - [DEBUG_STABLE] = {SAFE, VOID, "debug-stable", "Dt", false}, - [DEBUG_PROF] = {SAFE, VOID, "debug-prof", "Dp", false}, - [DEBUG_LINKER] = {SAFE, VOID, "debug-linker", "Dl", false}, - [DEBUG_LINKER_VERBOSE] = {SAFE, VOID, "debug-linker-verbose", "DL", false}, - [DEBUG_APPLY] = {SAFE, VOID, "debug-apply", "Da", false}, - [DEBUG_STM] = {SAFE, VOID, "debug-stm", "Dm", false}, - [DEBUG_SQUEEZE] = {SAFE, VOID, "debug-squeeze", "Dz", false}, - [DEBUG_HPC] = {SAFE, VOID, "debug-hpc", "Dc", false}, - [DEBUG_SPARKS] = {SAFE, VOID, "debug-sparks", "Dr", false}, - [DEBUG_COMPACT] = {SAFE, VOID, "debug-compact", "DC", false}, -// #endif - [MAX_STACK_SIZE] = {UNSAFE, STGWORD64, "stack-max-size", "K", true}, - [STACK_CHUNK_SIZE] = {UNSAFE, STGWORD64, "stack-chunk-size", "kc", true}, - [STACK_CHUNK_BUFFER_SIZE] = {UNSAFE, STGWORD64, "stack-chunk-buffer-size", "kb", true}, - [STACK_INITIAL_SIZE] = {UNSAFE, STGWORD64, "stack-initial-size", "ki", true}, + [DEBUG_SCHEDULER] = {SAFE, VOID, "debug-scheduler", "Ds", false}, + [DEBUG_INTERPRETER] = {SAFE, VOID, "debug-interpreter", "Di", false}, + [DEBUG_WEAK] = {SAFE, VOID, "debug-weak", "Dw", false}, + [DEBUG_GCCAFS] = {SAFE, VOID, "debug-gccafs", "DG", false}, + [DEBUG_GC] = {SAFE, VOID, "debug-gc", "Dg", false}, + [DEBUG_NONMOVING_GC] = {SAFE, VOID, "debug-nonmoving-gc", "Dn", false}, + [DEBUG_BLOCK_ALLOC] = {SAFE, VOID, "debug-block-alloc", "Db", false}, + [DEBUG_SANITY] = {SAFE, VOID, "debug-sanity", "DS", false}, + [DEBUG_ZERO_IN_GC] = {SAFE, VOID, "debug-zero-on-gc", "DZ", false}, + [DEBUG_STABLE] = {SAFE, VOID, "debug-stable", "Dt", false}, + [DEBUG_PROF] = {SAFE, VOID, "debug-prof", "Dp", false}, + [DEBUG_LINKER] = {SAFE, VOID, "debug-linker", "Dl", false}, + [DEBUG_LINKER_VERBOSE] = {SAFE, VOID, "debug-linker-verbose", "DL", false}, + [DEBUG_APPLY] = {SAFE, VOID, "debug-apply", "Da", false}, + [DEBUG_STM] = {SAFE, VOID, "debug-stm", "Dm", false}, + [DEBUG_SQUEEZE] = {SAFE, VOID, "debug-squeeze", "Dz", false}, + [DEBUG_HPC] = {SAFE, VOID, "debug-hpc", "Dc", false}, + [DEBUG_SPARKS] = {SAFE, VOID, "debug-sparks", "Dr", false}, + [DEBUG_COMPACT] = {SAFE, VOID, "debug-compact", "DC", false}, +// #endif + [MAX_STACK_SIZE] = {UNSAFE, STGWORD64, "stack-max-size", "K", true}, + [STACK_CHUNK_SIZE] = {UNSAFE, STGWORD64, "stack-chunk-size", "kc", true}, + [STACK_CHUNK_BUFFER_SIZE] = {UNSAFE, STGWORD64, "stack-chunk-buffer-size", "kb", true}, + [STACK_INITIAL_SIZE] = {UNSAFE, STGWORD64, "stack-initial-size", "ki", true}, + [HEAP_LIMIT_GRACE] = {UNSAFE, STGWORD64, "heap-limit-grace", "Mgrace", true}, + [HEAP_LIMIT_SIZE] = {UNSAFE, STGWORD64, "heap-limit-size", "M", true}, + // The 'NULL' of flags. Long name just for debugging - [UNKNOWN_RTS_OPTION] = {SAFE, VOID, "UNKNOWN_RTS_OPTION", NULL, false}, + [UNKNOWN_RTS_OPTION] = {SAFE, VOID, "UNKNOWN_RTS_OPTION", NULL, false}, }; static RtsFlagValue @@ -351,7 +354,7 @@ parse_flag_value(RtsFlagKey i, bool isLongName, char *arg0, bool *error) // account for '=' that is used with long-form names // some long-from names can have no value though so account for that as well if (isLongName && arg[offset] == '=') offset++; - if (hasValue && !is_valid_size(&arg[offset])) { + if (hasValue && !is_valid_size(arg + offset)) { BAD_VALUE(error, arg); } StgWord64 min; @@ -430,8 +433,17 @@ parse_flag_value(RtsFlagKey i, bool isLongName, char *arg0, bool *error) value = decodeSize(arg, offset, min, max, error); break; } + + case HEAP_LIMIT_GRACE: + case HEAP_LIMIT_SIZE: { + min = BLOCK_SIZE; + max = HS_WORD_MAX; + value = decodeSize(arg, offset, min, max, error); + break; + } } - if (*error) { + + if (*error) { // TODO: this can be other error - need abstraction here OUT_OF_RANGE(error, arg, min, max); } return STGWORD64_VAL(i, value); diff --git a/rts/include/rts/OptParse.h b/rts/include/rts/OptParse.h index 1e20ef1835..e933e79e12 100644 --- a/rts/include/rts/OptParse.h +++ b/rts/include/rts/OptParse.h @@ -76,6 +76,8 @@ typedef enum _RtsFlagKey { STACK_CHUNK_SIZE, STACK_CHUNK_BUFFER_SIZE, STACK_INITIAL_SIZE, + HEAP_LIMIT_GRACE, + HEAP_LIMIT_SIZE, UNKNOWN_RTS_OPTION, } RtsFlagKey; diff --git a/testsuite/tests/rts/OptParse/OptParseTest.c b/testsuite/tests/rts/OptParse/OptParseTest.c index 07f64956b1..b6fa9ba0c3 100644 --- a/testsuite/tests/rts/OptParse/OptParseTest.c +++ b/testsuite/tests/rts/OptParse/OptParseTest.c @@ -79,6 +79,9 @@ int main (int argc, char *argv[]) STGWORD64_FLAG_TEST(STACK_CHUNK_BUFFER_SIZE); STGWORD64_FLAG_TEST(STACK_INITIAL_SIZE); + STGWORD64_FLAG_TEST(HEAP_LIMIT_GRACE); + STGWORD64_FLAG_TEST(HEAP_LIMIT_SIZE); + printf("\n=== OptParseTest END ===\n"); return 0; } diff --git a/testsuite/tests/rts/OptParse/OptParseTest.stderr b/testsuite/tests/rts/OptParse/OptParseTest.stderr index 4cd048f693..baa7c81ccf 100644 --- a/testsuite/tests/rts/OptParse/OptParseTest.stderr +++ b/testsuite/tests/rts/OptParse/OptParseTest.stderr @@ -1988,3 +1988,159 @@ unknown RTS option: -ki=true (FAIL_TEST) input: -kijhgl unknown RTS option: -kijhgl + +(TEST) input: --heap-limit-grace=8193 +50: heap-limit-grace Mgrace UNSAFE +expected: 8193 actual: 8193 + +(TEST) input: --heap-limit-grace=8193K +50: heap-limit-grace Mgrace UNSAFE +expected: 8389632 actual: 8389632 + +(TEST) input: --heap-limit-grace=2M +50: heap-limit-grace Mgrace UNSAFE +expected: 2097152 actual: 2097152 + +(TEST) input: --heap-limit-grace=9G +50: heap-limit-grace Mgrace UNSAFE +expected: 9663676416 actual: 9663676416 + +(TEST) input: --heap-limit-grace=2G +50: heap-limit-grace Mgrace UNSAFE +expected: 2147483648 actual: 2147483648 + +(TEST) input: --heap-limit-grace=3333w +50: heap-limit-grace Mgrace UNSAFE +expected: 26664 actual: 26664 + +(FAIL_TEST) input: --heap-limit-grace= +unknown RTS option: --heap-limit-grace= + +(FAIL_TEST) input: --heap-limit-grace=fbar +bad value for heap-limit-grace=fbar + +(FAIL_TEST) input: --heap-limit-grace=false +bad value for heap-limit-grace=false + +(FAIL_TEST) input: --heap-limit-grace=true +bad value for heap-limit-grace=true + +(FAIL_TEST) input: --heap-limit-gracexxzag +unknown RTS option: --heap-limit-gracexxzag + +(TEST) input: -Mgrace8193 +50: heap-limit-grace Mgrace UNSAFE +expected: 8193 actual: 8193 + +(TEST) input: -Mgrace8193k +50: heap-limit-grace Mgrace UNSAFE +expected: 8389632 actual: 8389632 + +(TEST) input: -Mgrace2m +50: heap-limit-grace Mgrace UNSAFE +expected: 2097152 actual: 2097152 + +(TEST) input: -Mgrace9g +50: heap-limit-grace Mgrace UNSAFE +expected: 9663676416 actual: 9663676416 + +(TEST) input: -Mgrace1G +50: heap-limit-grace Mgrace UNSAFE +expected: 1073741824 actual: 1073741824 + +(TEST) input: -Mgrace3333w +50: heap-limit-grace Mgrace UNSAFE +expected: 26664 actual: 26664 + +(FAIL_TEST) input: -Mgrace= +unknown RTS option: -Mgrace= + +(FAIL_TEST) input: -Mgrace=baz +unknown RTS option: -Mgrace=baz + +(FAIL_TEST) input: -Mgrace=false +unknown RTS option: -Mgrace=false + +(FAIL_TEST) input: -Mgrace=true +unknown RTS option: -Mgrace=true + +(FAIL_TEST) input: -Mgracejhgl +unknown RTS option: -Mgracejhgl + +(TEST) input: --heap-limit-size=8193 +51: heap-limit-size M UNSAFE +expected: 8193 actual: 8193 + +(TEST) input: --heap-limit-size=8193K +51: heap-limit-size M UNSAFE +expected: 8389632 actual: 8389632 + +(TEST) input: --heap-limit-size=2M +51: heap-limit-size M UNSAFE +expected: 2097152 actual: 2097152 + +(TEST) input: --heap-limit-size=9G +51: heap-limit-size M UNSAFE +expected: 9663676416 actual: 9663676416 + +(TEST) input: --heap-limit-size=2G +51: heap-limit-size M UNSAFE +expected: 2147483648 actual: 2147483648 + +(TEST) input: --heap-limit-size=3333w +51: heap-limit-size M UNSAFE +expected: 26664 actual: 26664 + +(FAIL_TEST) input: --heap-limit-size= +unknown RTS option: --heap-limit-size= + +(FAIL_TEST) input: --heap-limit-size=fbar +bad value for heap-limit-size=fbar + +(FAIL_TEST) input: --heap-limit-size=false +bad value for heap-limit-size=false + +(FAIL_TEST) input: --heap-limit-size=true +bad value for heap-limit-size=true + +(FAIL_TEST) input: --heap-limit-sizexxzag +unknown RTS option: --heap-limit-sizexxzag + +(TEST) input: -M8193 +51: heap-limit-size M UNSAFE +expected: 8193 actual: 8193 + +(TEST) input: -M8193k +51: heap-limit-size M UNSAFE +expected: 8389632 actual: 8389632 + +(TEST) input: -M2m +51: heap-limit-size M UNSAFE +expected: 2097152 actual: 2097152 + +(TEST) input: -M9g +51: heap-limit-size M UNSAFE +expected: 9663676416 actual: 9663676416 + +(TEST) input: -M1G +51: heap-limit-size M UNSAFE +expected: 1073741824 actual: 1073741824 + +(TEST) input: -M3333w +51: heap-limit-size M UNSAFE +expected: 26664 actual: 26664 + +(FAIL_TEST) input: -M= +unknown RTS option: -M= + +(FAIL_TEST) input: -M=baz +unknown RTS option: -M=baz + +(FAIL_TEST) input: -M=false +unknown RTS option: -M=false + +(FAIL_TEST) input: -M=true +unknown RTS option: -M=true + +(FAIL_TEST) input: -Mjhgl +unknown RTS option: -Mjhgl diff --git a/testsuite/tests/rts/OptParse/OptParseTest.stdout b/testsuite/tests/rts/OptParse/OptParseTest.stdout index 5765b56d99..38ab193bb6 100644 --- a/testsuite/tests/rts/OptParse/OptParseTest.stdout +++ b/testsuite/tests/rts/OptParse/OptParseTest.stdout @@ -770,4 +770,100 @@ 49: stack-initial-size ki UNSAFE value: 26664 +(TEST) input: --heap-limit-grace=8193 +50: heap-limit-grace Mgrace UNSAFE + value: 8193 + +(TEST) input: --heap-limit-grace=8193K +50: heap-limit-grace Mgrace UNSAFE + value: 8389632 + +(TEST) input: --heap-limit-grace=2M +50: heap-limit-grace Mgrace UNSAFE + value: 2097152 + +(TEST) input: --heap-limit-grace=9G +50: heap-limit-grace Mgrace UNSAFE + value: 9663676416 + +(TEST) input: --heap-limit-grace=2G +50: heap-limit-grace Mgrace UNSAFE + value: 2147483648 + +(TEST) input: --heap-limit-grace=3333w +50: heap-limit-grace Mgrace UNSAFE + value: 26664 + +(TEST) input: -Mgrace8193 +50: heap-limit-grace Mgrace UNSAFE + value: 8193 + +(TEST) input: -Mgrace8193k +50: heap-limit-grace Mgrace UNSAFE + value: 8389632 + +(TEST) input: -Mgrace2m +50: heap-limit-grace Mgrace UNSAFE + value: 2097152 + +(TEST) input: -Mgrace9g +50: heap-limit-grace Mgrace UNSAFE + value: 9663676416 + +(TEST) input: -Mgrace1G +50: heap-limit-grace Mgrace UNSAFE + value: 1073741824 + +(TEST) input: -Mgrace3333w +50: heap-limit-grace Mgrace UNSAFE + value: 26664 + +(TEST) input: --heap-limit-size=8193 +51: heap-limit-size M UNSAFE + value: 8193 + +(TEST) input: --heap-limit-size=8193K +51: heap-limit-size M UNSAFE + value: 8389632 + +(TEST) input: --heap-limit-size=2M +51: heap-limit-size M UNSAFE + value: 2097152 + +(TEST) input: --heap-limit-size=9G +51: heap-limit-size M UNSAFE + value: 9663676416 + +(TEST) input: --heap-limit-size=2G +51: heap-limit-size M UNSAFE + value: 2147483648 + +(TEST) input: --heap-limit-size=3333w +51: heap-limit-size M UNSAFE + value: 26664 + +(TEST) input: -M8193 +51: heap-limit-size M UNSAFE + value: 8193 + +(TEST) input: -M8193k +51: heap-limit-size M UNSAFE + value: 8389632 + +(TEST) input: -M2m +51: heap-limit-size M UNSAFE + value: 2097152 + +(TEST) input: -M9g +51: heap-limit-size M UNSAFE + value: 9663676416 + +(TEST) input: -M1G +51: heap-limit-size M UNSAFE + value: 1073741824 + +(TEST) input: -M3333w +51: heap-limit-size M UNSAFE + value: 26664 + === OptParseTest END === |