From 5106d587c0325f3191696d5da5a1ce75ebfffaa7 Mon Sep 17 00:00:00 2001 From: Sergey Andreenko Date: Wed, 9 Jun 2021 15:53:19 -0700 Subject: [PATCH] fix spmi perfomance. (#53953) --- src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.cpp | 7 +++++-- src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.h | 2 ++ src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h | 8 +++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.cpp index 94ac3a5..729064a 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.cpp @@ -1096,7 +1096,10 @@ void CompileResult::repRecordCallSite(ULONG instrOffset, CORINFO_SIG_INFO* callS // The most call site records have only `methodHandle`, so creating two separate maps give us better perfomance // and smaller memory consumption. Note: we are not reading values from these maps during a normal replay. RecordCallSiteWithSignature = new LightWeightMap(); - RecordCallSiteWithoutSignature = new LightWeightMap(); + if (recordCallSitesWithoutSig) + { + RecordCallSiteWithoutSignature = new LightWeightMap(); + } } if (callSig != nullptr) @@ -1107,7 +1110,7 @@ void CompileResult::repRecordCallSite(ULONG instrOffset, CORINFO_SIG_INFO* callS value.methodHandle = CastHandle(methodHandle); RecordCallSiteWithSignature->Add(instrOffset, value); } - else + else if (recordCallSitesWithoutSig) { RecordCallSiteWithoutSignature->Add(instrOffset, CastHandle(methodHandle)); } diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.h b/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.h index 47dbc0a..4c912d1 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.h +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.h @@ -211,5 +211,7 @@ private: MemoryTracker* memoryTracker; Capture_AllocMemDetails allocMemDets; allocGCInfoDetails allocGCInfoDets; + + const bool recordCallSitesWithoutSig = false; // Set it to true if you want to use CallUtils::GetRecordedCallSiteInfo. }; #endif diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h b/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h index ed06e9f..dee5d76 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h @@ -385,11 +385,9 @@ public: if (numItems > 0) { - for (unsigned int i = numItems; i > insert; i--) - { - pKeys[i] = pKeys[i - 1]; - pItems[i] = pItems[i - 1]; - } + int countToMove = (numItems - insert); + memmove(&pKeys[insert+1], &pKeys[insert], countToMove * sizeof(pKeys[insert])); + memmove(&pItems[insert+1], &pItems[insert], countToMove * sizeof(pItems[insert])); } pKeys[insert] = key; -- 2.7.4