Skip to content

Commit

Permalink
Add size info for precompiled methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukul Sabharwal committed Aug 4, 2019
1 parent d51ab3f commit 932e547
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CoreCLRProfiler/native/BPerfProfilerCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ BPerfProfilerCallback::BPerfProfilerCallback()
/* Precompiled Methods Counters */
this->totalCachedMethodsSearched = 0;
this->totalCachedMethodsRestored = 0;
this->totalCachedMethodsMachineCodeBytesRestored = 0;

/* Runtime Suspension Counters */
this->totalNumberOfRuntimeSuspensions = 0;
Expand Down Expand Up @@ -273,6 +274,19 @@ HRESULT STDMETHODCALLTYPE BPerfProfilerCallback::JITCachedFunctionSearchFinished
if (result == COR_PRF_CACHED_FUNCTION_FOUND)
{
++this->totalCachedMethodsRestored;

ULONG32 cCodeInfos;
IfFailRet(this->corProfilerInfo->GetCodeInfo2(functionId, 0, &cCodeInfos, nullptr));
std::vector<COR_PRF_CODE_INFO> codeInfos(cCodeInfos);
IfFailRet(this->corProfilerInfo->GetCodeInfo2(functionId, cCodeInfos, &cCodeInfos, codeInfos.data()));

size_t codeSize = 0;
for (auto& s : codeInfos)
{
codeSize += s.size;
}

this->totalCachedMethodsMachineCodeBytesRestored += codeSize;
}

return S_OK;
Expand Down Expand Up @@ -796,6 +810,11 @@ size_t BPerfProfilerCallback::GetTotalCachedMethodsRestored() const
return this->totalCachedMethodsRestored;
}

size_t BPerfProfilerCallback::GetTotalCachedMethodsMachineCodeBytesRestored() const
{
return this->totalCachedMethodsMachineCodeBytesRestored;
}

/* Runtime Suspension Counters */
size_t BPerfProfilerCallback::GetTotalNumberOfRuntimeSuspsensions() const
{
Expand Down
2 changes: 2 additions & 0 deletions CoreCLRProfiler/native/BPerfProfilerCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class BPerfProfilerCallback final : public ICorProfilerCallback9
/* Precompiled Method Counters */
size_t GetTotalCachedMethodsSearched() const;
size_t GetTotalCachedMethodsRestored() const;
size_t GetTotalCachedMethodsMachineCodeBytesRestored() const;

/* Runtime Suspension Counters */
size_t GetTotalNumberOfRuntimeSuspsensions() const;
Expand Down Expand Up @@ -237,6 +238,7 @@ class BPerfProfilerCallback final : public ICorProfilerCallback9
/* Precompiled Methods Counters */
std::atomic<size_t> totalCachedMethodsSearched;
std::atomic<size_t> totalCachedMethodsRestored;
std::atomic<size_t> totalCachedMethodsMachineCodeBytesRestored;

/* Runtime Suspension Counters */
std::atomic<size_t> totalNumberOfRuntimeSuspensions;
Expand Down
5 changes: 5 additions & 0 deletions CoreCLRProfiler/native/Microsoft.BPerf.CoreCLRProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ extern "C" size_t GetTotalCachedMethodsRestored()
return ProfilerInstance->GetTotalCachedMethodsRestored();
}

extern "C" size_t GetTotalCachedMethodsMachineCodeBytesRestored()
{
return ProfilerInstance->GetTotalCachedMethodsMachineCodeBytesRestored();
}

/* Runtime Suspension Counters */
extern "C" size_t GetTotalNumberOfRuntimeSuspsensions()
{
Expand Down
1 change: 1 addition & 0 deletions CoreCLRProfiler/native/exports.def
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ EXPORTS
GetCurrentNumberOfDynamicMethods
GetTotalCachedMethodsSearched
GetTotalCachedMethodsRestored
GetTotalCachedMethodsMachineCodeBytesRestored
GetTotalNumberOfRuntimeSuspsensions
GetTotalNumberOfRuntimeSuspensionsForGC
GetTotalNumberOfRuntimeSuspensionsForGCPrep
Expand Down

0 comments on commit 932e547

Please sign in to comment.