Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 052f5a2

Browse files
committed
Added 2 HardLimit configs -
GCHeapHardLimit - specifies a hard limit for the GC heap GCHeapHardLimitPercent - specifies a percentage of the physical memory this process is allowed to use If both are specified, GCHeapHardLimit is checked first and only when it's not specified would we check GCHeapHardLimitPercent. If neither is specified but the process is running inside a container with a memory limit specified, we will take this as the hard limit: max (20mb, 75% of the memory limit on the container) If one of the HardLimit configs is specified, and the process is running inside a container with a memory limit, the GC heap usage will not exceed the HardLimit but the total memory is still the memory limit on the container so when we calculate the memory load it's based off the container memory limit. An example, process is running inside a container with 200mb limit user also specified GCHeapHardLimit as 100mb. if 50mb out of the 100mb is used for GC, and 100mb is used for other things, the memory load is (50 + 100)/200 = 75%. Some notes on these configs - + This is only supported on 64-bit. + For Server GC the minimum *reserved* segment size is 16mb per heap, this is to avoid the scenario where the hard limit is small but the process can use many procs and we end up with tiny segments which doesn't make sense. We then keep track of the committed on the segments so the total does not exceed the hard limit.
1 parent acbfc3d commit 052f5a2

File tree

14 files changed

+875
-272
lines changed

14 files changed

+875
-272
lines changed

src/ToolBox/SOS/Strike/sos.def

-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ EXPORTS
2323
dumpdelegate=DumpDelegate
2424
DumpDomain
2525
dumpdomain=DumpDomain
26-
#ifdef TRACE_GC
2726
DumpGCLog
2827
dumpgclog=DumpGCLog
2928
dlog=DumpGCLog
30-
#endif
3129
DumpGCData
3230
dumpgcdata=DumpGCData
3331
dgc=DumpGCData

src/ToolBox/SOS/Strike/strike.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -9419,8 +9419,7 @@ DECLARE_API(DumpLog)
94199419
return Status;
94209420
}
94219421

9422-
#ifdef TRACE_GC
9423-
9422+
#ifndef FEATURE_PAL
94249423
DECLARE_API (DumpGCLog)
94259424
{
94269425
INIT_API_NODAC();
@@ -9433,6 +9432,10 @@ DECLARE_API (DumpGCLog)
94339432
}
94349433

94359434
const char* fileName = "GCLog.txt";
9435+
int iLogSize = 1024*1024;
9436+
BYTE* bGCLog = NULL;
9437+
int iRealLogSize = iLogSize - 1;
9438+
DWORD dwWritten = 0;
94369439

94379440
while (isspace (*args))
94389441
args ++;
@@ -9477,8 +9480,7 @@ DECLARE_API (DumpGCLog)
94779480
goto exit;
94789481
}
94799482

9480-
int iLogSize = 1024*1024;
9481-
BYTE* bGCLog = new NOTHROW BYTE[iLogSize];
9483+
bGCLog = new NOTHROW BYTE[iLogSize];
94829484
if (bGCLog == NULL)
94839485
{
94849486
ReportOOM();
@@ -9491,7 +9493,6 @@ DECLARE_API (DumpGCLog)
94919493
ExtOut("failed to read memory from %08x\n", dwAddr);
94929494
}
94939495

9494-
int iRealLogSize = iLogSize - 1;
94959496
while (iRealLogSize >= 0)
94969497
{
94979498
if (bGCLog[iRealLogSize] != '*')
@@ -9502,13 +9503,17 @@ DECLARE_API (DumpGCLog)
95029503
iRealLogSize--;
95039504
}
95049505

9505-
DWORD dwWritten = 0;
95069506
WriteFile (hGCLog, bGCLog, iRealLogSize + 1, &dwWritten, NULL);
95079507

95089508
Status = S_OK;
95099509

95109510
exit:
95119511

9512+
if (bGCLog != NULL)
9513+
{
9514+
delete [] bGCLog;
9515+
}
9516+
95129517
if (hGCLog != INVALID_HANDLE_VALUE)
95139518
{
95149519
CloseHandle (hGCLog);
@@ -9523,9 +9528,7 @@ DECLARE_API (DumpGCLog)
95239528

95249529
return Status;
95259530
}
9526-
#endif //TRACE_GC
95279531

9528-
#ifndef FEATURE_PAL
95299532
DECLARE_API (DumpGCConfigLog)
95309533
{
95319534
INIT_API();

src/gc/env/gcenv.os.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,14 @@ class GCToOSInterface
341341
// Get the physical memory that this process can use.
342342
// Return:
343343
// non zero if it has succeeded, 0 if it has failed
344+
// *is_restricted is set to true if asked and running in restricted.
344345
// Remarks:
345346
// If a process runs with a restricted memory limit, it returns the limit. If there's no limit
346347
// specified, it returns amount of actual physical memory.
347-
static uint64_t GetPhysicalMemoryLimit();
348+
//
349+
// PERF TODO: Requires more work to not treat the restricted case to be special.
350+
// To be removed before 3.0 ships.
351+
static uint64_t GetPhysicalMemoryLimit(bool* is_restricted=NULL);
348352

349353
// Get memory status
350354
// Parameters:

0 commit comments

Comments
 (0)