-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Support passing total code size through when doing SPMI diffs #60124
Conversation
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.
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsCurrently the total code bytes shown for the base/diff is misleading
The net result is that the displayed results from jit-analyze after SPMI
|
cc @dotnet/jit-contrib |
@BruceForstall Indeed, I missed that issue. I don't think the changes to jit-analyze in this PR are what we ultimately will want once we start addressing #52877, but I think for now that it will suffice. |
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.
This looks great; thanks for doing this!
I presume you have a corresponding jit-analyze PR to submit?
Whoops, yes, I totally forgot that it won't be part of this PR. Opened dotnet/jitutils#337. |
May be I am missing something, but will |
superpmi.py does not have any new args, it passes |
Ok..now I understand and in future, we can make |
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.
LGTM
How is it supposed to work when "diff" has spmi misses (because of the change) and so it has smaller size, in my case I see:
so it is more misleading than the old version in this scenario, is not it? |
@sandreenko You're talking about when the "diff" compiler causes SuperPMI to hit "missing data" exceptions in some functions due to changed JIT/EE interface traffic compared to the collection? In that case, we (I believe) fail the asm diff at the superpmi.exe stage, so we don't generate base/diff textual .dasm. So, yes, it's then biased because anything that failed is, essentially, not considered part of the collection at all. That seems reasonable, though. Is there some other reason why the overall baseline bytes is different from the overall diff bytes? Did the JIT fail to generate some of the textual .dasm files? |
@@ -365,11 +368,16 @@ JitInstance::Result JitInstance::CompileMethod(MethodContext* MethodToCompile, i | |||
pParam->pThis->mc->cr->recAllocGCInfoCapture(); | |||
|
|||
pParam->pThis->mc->cr->recMessageLog("Successful Compile"); | |||
|
|||
pParam->metrics->SuccessfulCompiles++; | |||
pParam->metrics->NumCodeBytes += NCodeSizeBlock; |
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.
@BruceForstall Yes, but if it passes in "base" then we write its size to NumCodeBytes
and we don't know that it will fail in diff, so we ignore asm files as you say but this new metric does not look at asm files if I read the change correctly.
So we pass --override-total-base-metric
as total number of bytes from compiled methods with base and --override-total-diff-metric
as total number of bytes from compiled methods with diff.
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.
I see, we actually are adding the code size before we do the asmdiff. It seems like we should delay until after InvokeNearDiffer
is successful (either shows no diffs or some diffs, but doesn't crash) before adding the code size. @jakobbotsch ?
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.
Sure, that might make sense. But if there are misses then posting the summary is misleading in any case because it does not show any diff in those methods, which is probably where the diffs will actually be. So at least this way it is visible to me that there are roughly 7 KB of code that SPMI misses now and that you should probably post PMI diffs instead.
I can change it but I don't see how we can make this case not be misleading to the reader of the summary.
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.
I guess it has to be wordy, like
Total metric of base: 7178021 bytes, 101 methods;
Total metric of diff: 7171065 bytes, 100 methods;
Total metric of delta: -6956 bytes differs (-0.10% of base), -1 method (-1% of base)
Total metric of delta in matching methods: +100 (+0.1 of base) on 100 methods.
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.
But the numbers are not useful, since what I would be interested in as a reader is the diffs in the failed methods. The idea behind this change was to get a better overview of how the change affects libraries crossgen/PMI as a whole and we can never get that when there's missing data. When I see the "Missing data encountered" I always use PMI for my diffs instead.
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.
We could sum the code bytes in the dasm files in jit-analyze and at least give a clear warning that they do not account for all diffs. But this only helps if someone does not notice that SPMI diffs are only partial and then posts the results anyway, not sure if this is what we're afraid of?
Are there are cases where we know there won't be diffs in the functions with missing data encountered so that the SPMI diffs give an accurate view anyway? I can see keeping track of a "number of diffed code bytes" metric as @BruceForstall suggested for this case, but in other cases it seems we should not use SPMI for diffs.
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:
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.
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
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.