Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 9 additions & 3 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6329,8 +6329,6 @@ void Compiler::compCompileFinish()
JitMemStatsInfo::finishMemStats(compArenaAllocator);
memAllocHist.record((unsigned)((compArenaAllocator->getTotalBytesAllocated() + 1023) / 1024));
memUsedHist.record((unsigned)((compArenaAllocator->getTotalBytesUsed() + 1023) / 1024));

Metrics.BytesAllocated = (int64_t)compArenaAllocator->getTotalBytesUsed();
}

#ifdef DEBUG
Expand All @@ -6342,6 +6340,11 @@ void Compiler::compCompileFinish()
#endif // DEBUG
#endif // MEASURE_MEM_ALLOC

if (JitConfig.JitReportMetrics())
{
Metrics.BytesAllocated = (int64_t)compArenaAllocator->getTotalBytesUsed();
}

#if LOOP_HOIST_STATS
AddLoopHoistStats();
#endif // LOOP_HOIST_STATS
Expand Down Expand Up @@ -6545,7 +6548,10 @@ void Compiler::compCompileFinish()
}

JITDUMP("Final metrics:\n");
Metrics.report(this);
if (JitConfig.JitReportMetrics())
{
Metrics.report(this);
}
DBEXEC(verbose, Metrics.dump());

if (verbose)
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,9 @@ RELEASE_CONFIG_STRING(AltJitExcludeAssemblies, "AltJitExcludeAssemblies")
// If set, measure the IR size after some phases and report it in the time log.
RELEASE_CONFIG_INTEGER(JitMeasureIR, "JitMeasureIR", 0)

// If set, report JIT metrics back to the EE after each method compilation.
RELEASE_CONFIG_INTEGER(JitReportMetrics, "JitReportMetrics", 0)

// If set, gather JIT function info and write to this file.
RELEASE_CONFIG_STRING(JitFuncInfoFile, "JitFuncInfoLogFile")

Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/jit/jitmetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "jitpch.h"
#include "jitmetadata.h"

#ifdef DEBUG

//------------------------------------------------------------------------
// JitMetadata::report: Report metadata back to the EE.
//
Expand Down Expand Up @@ -46,6 +44,9 @@ void JitMetrics::report(Compiler* comp)
#include "jitmetadatalist.h"
}

#ifdef DEBUG
// The remaining functions are only used in debug builds.

//------------------------------------------------------------------------
// JitMetrics::mergeToRoot: Merge inlinee compiler metrics to root compiler instance
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ int JitHost::getIntConfigValue(const char* key, int defaultValue)
// even record that it was called (since it would get recorded into the
// global state). (See the superpmi.exe tool implementation of JitHost::getIntConfigValue()
// for the special-case implementation of this.)
if (strcmp(key, "SuperPMIMethodContextNumber") == 0)
if (strcmp(key, "SuperPMIMethodContextNumber") == 0 ||
strcmp(key, "JitReportMetrics") == 0)
{
return defaultValue;
}
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/tools/superpmi/superpmi/jithost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ int JitHost::getIntConfigValue(const char* key, int defaultValue)
result = jitInstance.mc->index;
valueFound = true;
}
else if (strcmp(key, "JitReportMetrics") == 0)
{
result = 1;
valueFound = true;
}
}

if (!valueFound)
Expand Down
Loading