fix spmi perfomance. (#53953)
authorSergey Andreenko <seandree@microsoft.com>
Wed, 9 Jun 2021 22:53:19 +0000 (15:53 -0700)
committerGitHub <noreply@github.com>
Wed, 9 Jun 2021 22:53:19 +0000 (15:53 -0700)
src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.cpp
src/coreclr/ToolBox/superpmi/superpmi-shared/compileresult.h
src/coreclr/ToolBox/superpmi/superpmi-shared/lightweightmap.h

index 94ac3a5..729064a 100644 (file)
@@ -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<DWORD, Agnostic_RecordCallSite>();
-        RecordCallSiteWithoutSignature = new LightWeightMap<DWORD, DWORDLONG>();
+        if (recordCallSitesWithoutSig)
+        {
+            RecordCallSiteWithoutSignature = new LightWeightMap<DWORD, DWORDLONG>();
+        }
     }
 
     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));
     }
index 47dbc0a..4c912d1 100644 (file)
@@ -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
index ed06e9f..dee5d76 100644 (file)
@@ -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;