-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MCS verb to dump jit flags histogram #48281
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
#include "standardpch.h" | ||
#include "verbjitflags.h" | ||
#include "methodcontext.h" | ||
#include "methodcontextiterator.h" | ||
#include "errorhandling.h" | ||
#include "spmidumphelper.h" | ||
|
||
int verbJitFlags::DoWork(const char* nameOfInput) | ||
{ | ||
MethodContextIterator mci; | ||
if (!mci.Initialize(nameOfInput)) | ||
return -1; | ||
|
||
LightWeightMap<unsigned long long, unsigned> flagMap; | ||
unsigned mcCount = 0; | ||
|
||
while (mci.MoveNext()) | ||
{ | ||
MethodContext* mc = mci.Current(); | ||
CORJIT_FLAGS corJitFlags; | ||
mc->repGetJitFlags(&corJitFlags, sizeof(corJitFlags)); | ||
unsigned long long rawFlags = corJitFlags.GetFlagsRaw(); | ||
|
||
int index = flagMap.GetIndex(rawFlags); | ||
if (index == -1) | ||
{ | ||
flagMap.Add(rawFlags, 1); | ||
} | ||
else | ||
{ | ||
int oldVal = flagMap.GetItem(index); | ||
flagMap.Update(index, oldVal + 1); | ||
} | ||
|
||
mcCount++; | ||
} | ||
|
||
if (!mci.Destroy()) | ||
return -1; | ||
|
||
printf("\nGrouped Flag Appearances (%u contexts)\n\n", mcCount); | ||
printf("%-16s %8s %8s parsed\n", "bits", "count", "percent"); | ||
|
||
unsigned appearancesPerBit[64] = {}; | ||
|
||
const unsigned int count = flagMap.GetCount(); | ||
unsigned long long* pFlags = flagMap.GetRawKeys(); | ||
|
||
for (unsigned int i = 0; i < count; i++) | ||
{ | ||
const unsigned long long flags = *pFlags++; | ||
const int index = flagMap.GetIndex(flags); | ||
const unsigned appearances = flagMap.GetItem(index); | ||
|
||
printf("%016llx %8u %7.2f%% %s\n", flags, appearances, 100.0 * ((double) appearances / mcCount), SpmiDumpHelper::DumpJitFlags(flags).c_str()); | ||
|
||
for (unsigned int bit = 0; bit < 64; bit++) | ||
{ | ||
if (flags & (1ull << bit)) | ||
{ | ||
appearancesPerBit[bit] += appearances; | ||
} | ||
} | ||
} | ||
|
||
printf("\nIndividual Flag Appearances\n\n"); | ||
for (unsigned int bit = 0; bit < 64; bit++) | ||
{ | ||
unsigned perBit = appearancesPerBit[bit]; | ||
if (perBit > 0) | ||
{ | ||
printf("%8u %7.2f%% %s\n", perBit, 100.0 * (double) perBit / mcCount, SpmiDumpHelper::DumpJitFlags(1ull<<bit).c_str()); | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
// | ||
|
||
//---------------------------------------------------------- | ||
// verbJitFlags.h - verb that prints summary of jit flags values | ||
//---------------------------------------------------------- | ||
#ifndef _verbJitFlags | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a preference between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think ifndef is preferable; it doesn't depend on support for |
||
#define _verbJitFlags | ||
|
||
class verbJitFlags | ||
{ | ||
public: | ||
static int DoWork(const char* nameOfInput); | ||
}; | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: looks like files in ToolBox/superpmi have their own license header, the standard one is:
is it expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that.
I think we need to redo all the license headers in these files. cc @BruceForstall