Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally capture a dump during generational aware analysis #54517

Merged
merged 3 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisGen, W("GCGenAnalysisGen"), 0, "T
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisBytes, W("GCGenAnalysisBytes"), 0, "The number of bytes to trigger generational aware analysis")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisIndex, W("GCGenAnalysisIndex"), 0, "The gc index to trigger generational aware analysis")
RETAIL_CONFIG_STRING_INFO(INTERNAL_GCGenAnalysisCmd, W("GCGenAnalysisCmd"), "An optional filter to match with the command line used to spawn the process")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_GCGenAnalysisDump, W("GCGenAnalysisDump"), 0, "Enable/Disable capturing a dump as well as the traces")

//
// Diagnostics Ports
Expand Down
13 changes: 13 additions & 0 deletions src/coreclr/vm/gcenv.ee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,19 @@ void GCToEEInterface::AnalyzeSurvivorsFinished(size_t gcIndex, int condemnedGene
s_forcedGCInProgress = false;
reportGenerationBounds();
FireEtwGenAwareEnd((int)gcIndex, GetClrInstanceId());
if (gcGenAnalysisDump)
{
EX_TRY
{
#ifdef HOST_WIN32
GenerateCrashDump (GENAWARE_DUMP_FILE_NAME, 2, false);
#else
PAL_GenerateCoreDump (GENAWARE_DUMP_FILE_NAME, 2, false);
#endif
}
EX_CATCH {}
EX_END_CATCH(SwallowAllExceptions);
}
EventPipeAdapter::PauseSession(gcGenAnalysisEventPipeSession);
gcGenAnalysisState = GcGenAnalysisState::Done;
EnableFinalization(true);
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/vm/genanalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int64_t gcGenAnalysisGen = -1;
int64_t gcGenAnalysisBytes = 0;
int64_t gcGenAnalysisIndex = 0;
uint32_t gcGenAnalysisBufferMB = 0;
bool gcGenAnalysisDump = false;

/* static */ void GenAnalysis::Initialize()
{
Expand Down Expand Up @@ -41,6 +42,7 @@ uint32_t gcGenAnalysisBufferMB = 0;
gcGenAnalysisGen = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisGen);
gcGenAnalysisIndex = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisIndex);
gcGenAnalysisBufferMB = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EventPipeCircularMB);
gcGenAnalysisDump = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_GCGenAnalysisDump);
gcGenAnalysisConfigured = GcGenAnalysisState::Enabled;
}
else
Expand All @@ -52,13 +54,13 @@ uint32_t gcGenAnalysisBufferMB = 0;
#endif
{
EnableGenerationalAwareSession();
}
}
}

/* static */ void GenAnalysis::EnableGenerationalAwareSession()
{
LPCWSTR outputPath = nullptr;
outputPath = GENAWARE_FILE_NAME;
outputPath = GENAWARE_TRACE_FILE_NAME;
NewArrayHolder<COR_PRF_EVENTPIPE_PROVIDER_CONFIG> pProviders;
int providerCnt = 1;
pProviders = new COR_PRF_EVENTPIPE_PROVIDER_CONFIG[providerCnt];
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/vm/genanalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum GcGenAnalysisState
Done = 3,
};

#define GENAWARE_FILE_NAME W("gcgenaware.nettrace")
#define GENAWARE_TRACE_FILE_NAME W("gcgenaware.nettrace")
#define GENAWARE_DUMP_FILE_NAME W("gcgenaware.dmp")
#define GENAWARE_COMPLETION_FILE_NAME "gcgenaware.nettrace.completed"

extern bool s_forcedGCInProgress;
Expand All @@ -29,6 +30,7 @@ extern GcGenAnalysisState gcGenAnalysisConfigured;
extern int64_t gcGenAnalysisGen;
extern int64_t gcGenAnalysisBytes;
extern int64_t gcGenAnalysisIndex;
extern bool gcGenAnalysisDump;

class GenAnalysis
{
Expand Down