1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-07 16:56:00 +02:00

Added diagnostics panel

This commit is contained in:
Brian Fiete 2020-07-31 06:16:29 -07:00
parent efa9566f88
commit f034880723
12 changed files with 1017 additions and 51 deletions

View file

@ -663,6 +663,15 @@ BFGC::BFGC()
for (int i = 0; i < kNumClasses; i++)
gGCDbgData.mSizeClasses[i] = Static::sizemap()->ByteSizeForClass(i);
mStats = NULL;
Beefy::String memName = StrFormat("BFGC_stats_%d", GetCurrentProcessId());
auto* fileMapping = ::CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(Stats), memName.c_str());
if (fileMapping != NULL)
{
mStats = (Stats*)MapViewOfFile(fileMapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(Stats));
mStats->mHeapSize = 0;
}
RawInit();
}
@ -1816,6 +1825,13 @@ void BFGC::FinishCollect()
mStage = 4;
}
void BFGC::UpdateStats()
{
if (mStats == NULL)
return;
mStats->mHeapSize = TCMalloc_SystemTaken;
}
void BFGC::Run()
{
BfpThread_SetName(BfpThread_GetCurrent(), "BFGC", NULL);
@ -1824,6 +1840,8 @@ void BFGC::Run()
while (!mExiting)
{
UpdateStats();
float fullGCPeriod = mFullGCPeriod;
if ((fullGCPeriod != -1) && (mMaxPausePercentage > 0) && (!mCollectReports.IsEmpty()))
{
@ -1835,7 +1853,7 @@ void BFGC::Run()
fullGCPeriod = BF_MIN(fullGCPeriod, maxExpandPeriod);
}
int waitPeriod = fullGCPeriod;
int waitPeriod = BF_MIN(fullGCPeriod, 100);
if (waitPeriod == 0)
waitPeriod = -1;
mCollectEvent.WaitFor(waitPeriod);

View file

@ -164,6 +164,11 @@ namespace tcmalloc_raw
class BFGC
{
public:
struct Stats
{
intptr mHeapSize;
};
struct ThreadInfo
{
static BF_TLS_DECLSPEC ThreadInfo* sCurThreadInfo;
@ -276,6 +281,7 @@ public:
BfpThreadId mThreadId;
Stats* mStats;
volatile bool mExiting;
volatile bool mRunning;
bool mGracelessShutdown;
@ -368,6 +374,7 @@ public:
void DoCollect(bool doingFullGC);
void FinishCollect();
void UpdateStats();
void Run();
static void BFP_CALLTYPE RunStub(void* gc);