-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support passing total code size through when doing SPMI diffs (#60124)
Currently the total code bytes shown for the base/diff is misleading when SPMI is used because SPMI generates only .dasm files for method contexts with diffs. This change: * Adds -baseMetricsSummary and -diffMetricsSummary to SPMI, which specifies a file path to output metrics. Currently that's just the number of failing/succeeding compiles, and the total number of code bytes, but the hope is to use this for other metrics as well. * Adds --override-total-base-metric and --override-total-diff-metric to jit-analyze, to support overriding the computed total base and total diff metric, since they are misleading when .dasm files are only created for differences * Supports this from the superpmi.py wrapper script for asmdiffs when no explicit metric is provided: in this case, the script will get the metrics from SPMI and pass them to jit-analyze to override the computed totals. The net result is that the displayed results from jit-analyze after SPMI runs are less misleading and should be more comparable to similar PMI runs.
- Loading branch information
1 parent
eff8883
commit b66a114
Showing
13 changed files
with
371 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#include "standardpch.h" | ||
#include "metricssummary.h" | ||
#include "logging.h" | ||
|
||
struct HandleCloser | ||
{ | ||
void operator()(HANDLE hFile) | ||
{ | ||
CloseHandle(hFile); | ||
} | ||
}; | ||
|
||
struct FileHandleWrapper | ||
{ | ||
FileHandleWrapper(HANDLE hFile) | ||
: hFile(hFile) | ||
{ | ||
} | ||
|
||
~FileHandleWrapper() | ||
{ | ||
CloseHandle(hFile); | ||
} | ||
|
||
HANDLE get() { return hFile; } | ||
|
||
private: | ||
HANDLE hFile; | ||
}; | ||
|
||
bool MetricsSummary::SaveToFile(const char* path) | ||
{ | ||
FileHandleWrapper file(CreateFile(path, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr)); | ||
if (file.get() == INVALID_HANDLE_VALUE) | ||
{ | ||
return false; | ||
} | ||
|
||
char buffer[4096]; | ||
int len = | ||
sprintf_s(buffer, sizeof(buffer), "Successful compiles,Failing compiles,Code bytes\n%d,%d,%lld\n", | ||
SuccessfulCompiles, FailingCompiles, NumCodeBytes); | ||
DWORD numWritten; | ||
if (!WriteFile(file.get(), buffer, static_cast<DWORD>(len), &numWritten, nullptr) || numWritten != static_cast<DWORD>(len)) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool MetricsSummary::LoadFromFile(const char* path, MetricsSummary* metrics) | ||
{ | ||
FileHandleWrapper file(CreateFile(path, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr)); | ||
if (file.get() == INVALID_HANDLE_VALUE) | ||
{ | ||
return false; | ||
} | ||
|
||
LARGE_INTEGER len; | ||
if (!GetFileSizeEx(file.get(), &len)) | ||
{ | ||
return false; | ||
} | ||
|
||
std::vector<char> content(static_cast<size_t>(len.QuadPart)); | ||
DWORD numRead; | ||
if (!ReadFile(file.get(), content.data(), static_cast<DWORD>(content.size()), &numRead, nullptr) || numRead != content.size()) | ||
{ | ||
return false; | ||
} | ||
|
||
if (sscanf_s(content.data(), "Successful compiles,Failing compiles,Code bytes\n%d,%d,%lld\n", | ||
&metrics->SuccessfulCompiles, &metrics->FailingCompiles, &metrics->NumCodeBytes) != 3) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void MetricsSummary::AggregateFrom(const MetricsSummary& other) | ||
{ | ||
SuccessfulCompiles += other.SuccessfulCompiles; | ||
FailingCompiles += other.FailingCompiles; | ||
NumCodeBytes += other.NumCodeBytes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#ifndef _MetricsSummary | ||
#define _MetricsSummary | ||
|
||
class MetricsSummary | ||
{ | ||
public: | ||
int SuccessfulCompiles; | ||
int FailingCompiles; | ||
long long NumCodeBytes; | ||
|
||
MetricsSummary() | ||
: SuccessfulCompiles(0) | ||
, FailingCompiles(0) | ||
, NumCodeBytes(0) | ||
{ | ||
} | ||
|
||
bool SaveToFile(const char* path); | ||
static bool LoadFromFile(const char* path, MetricsSummary* metrics); | ||
void AggregateFrom(const MetricsSummary& other); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.