Eliminate duplicate SSA number bookkeeping#15011
Conversation
c70ee9c to
349dbe5
Compare
|
Test failure in x86 Release build appears to be unrelated: Exit code seems to match Retrying. @dotnet-bot test Windows_NT x86 Release Innerloop Build and Test |
|
@dotnet/jit-contrib Has anyone seen a test failing as above, with that specific exit code? I can't reproduce the failure locally and I don't get any jit-diffs. I thought that it's just some sort of glitch in CI but on retry it failed exactly the same way. Any suggestions how to figure out what's going on? |
|
The HardwareIntrinsics tests are sensitive to the target that they are run on. It may be that the CI machine that it's running on has a different level of hardware support. You could try setting the various |
|
@CarolEidt Thanks! I actually did diffs by running the test with The root cause is that I can send a fix later today. IMO it should be ported to 2.1, I suppose this bug may happen even without my changes and then you'll be looking at some strange failures that are difficult to investigate. |
|
@mikedn - excellent! Thanks for tracking that down. |
88f1dab to
5573241
Compare
014b4a7 to
0282351
Compare
|
Seems like we should tag this with jit throughput too. @mikedn anything else we need here other than review signoff? |
|
@AndyAyersMS Yep, it's mainly about throughput, contributes to #15108. Though you could add a "CleanUpTheMess" label if you have one 😁. I'm not sure how the JIT ended up with bogus stuff like I need to fix the |
During SSA construction SsaRenameState keeps a definition count for each variable in an array. But each variable has a lvPerSsaData array that does almost the same thing, count the definitions. "Almost" because lvPerSsaData is a JitExpandArray that tracks only the array size and not the number of elements actually stored in the array. Replace JitExpandArray with purposely designed "array" that is in charge with allocating new SSA numbers and handles their intricacies - RESERVED_SSA_NUM, UNINIT_SSA_NUM and FIRST_SSA_NUM. This also allows the removal of the allocator from the array. Allocating new SSA numbers happens only during SSA construction and it's reasonable to pass the allocator to AllocSsaNum rather than increasing the size of PerSsaArray and LclVarDsc.
This is not used. It is generated by SsaRenameState::CountForUse when the lclvar stack is empty but that cannot happen - SsaBuilder::RenameVariables starts by assigning SSA numbers to all variables that are live at the start of fgFirstBB. And if it happens, well, there's a bug somewhere and falling back to minopts via a noway_assert is the appropriate thing to do.
|
https://ci.dot.net/job/dotnet_coreclr/job/master/job/x64_checked_osx10.12_corefx_innerloop_prtest/378/consoleText @dotnet-bot test OSX10.12 x64 Checked CoreFX Tests |
|
Might as well retry one more time. @dotnet-bot retest OSX10.12 x64 Checked CoreFX Tests |
AndyAyersMS
left a comment
There was a problem hiding this comment.
Changes LGTM, but perhaps we should have somebody else weigh in too...
|
Seems odd to me that we have a per-local dense array mapping ssa numbers to |
You mean that perhaps there should be a single array of LclSsaVarDsc? I though about that a bit back then when I did this. Right now it's not clear if it would be better/worse/useful:
|
|
Your comment got me thinking a bit more about using a single array for SSA definitions. It's actually pretty easy to implement on top of this, we just need a bit of care with array sizing. Using Using a single array has the advantage of making But it's a change that can go in a separate PR, this one can be considered as a step along the way. And will probably need #15351 as well to get rid of SSA numbers being assigned to non tracked lclvars. |
|
FWIW, it looks like it would be possible to replace the SSA number stored in LclVar nodes with a pointer, without increasing the node size. Then we wouldn't need the SSA def array anymore. But that starts to move into SSA redesign territory. And then, with a bit more work we may discover that we don't need even LclVar nodes. But that's far in the future, if ever. |
|
I was kind of hoping to see another, more "front-end" oriented JIT dev review this, but I've taken a look and it LGTM. I'm less familiar with the memory SSA than the lclVar SSA, but both sets of changes look reasonable to me. These changes definitely improve the clarity - I might suggest (in future) that we change the "count" terminology (which has always thrown me). |
@CarolEidt Where? I already made many |
|
We still refer to the ssa names / ssaNums as "counts" in places like However, IMO we should merge this and consider doing that at another time. |
Ah, those, I'm planning to rename as part of #15000 since that cleans up the rest of the rename stack code. |
Awesome! A quick glance at that looks like it will be quite an improvement |
During SSA construction
SsaRenameStatekeeps a definition count for each variable in an array. But each variable has alvPerSsaDataarray that does almost the same thing, count definitions. "Almost" becauselvPerSsaDatais aJitExpandArraythat tracks only the array size and not the number of elements actually stored in the array.Replace
JitExpandArraywith purposely designed "array" that is in charge with allocating new SSA numbers and handles their intricacies -RESERVED_SSA_NUM,UNINIT_SSA_NUMandFIRST_SSA_NUM.This also allows the removal of the allocator from the array. Allocating new SSA numbers happens only during SSA construction and it's reasonable to pass the allocator to
AllocSsaNumrather than increase the size ofPerSsaArrayandLclVarDsc.While working on this I realized that
UNINIT_SSA_NUMisn't actually needed.SsaBuilder::RenameVariablesstarts by assigning SSA numbers to all variables that are live at the start offgFirstBBso it's not possible to encounter an use without a def on the SSA rename stack. And if it happens, well, there's a bug somewhere and falling back to minopts via anoway_assertis the appropriate thing to do.No jit diffs.
0.28% less instructions retired and 0.6% less used memory.
PIN data: https://1drv.ms/x/s!Av4baJYSo5pjgr15HNl1qFfUxIWI8g
MemStats diff: https://gist.github.com/mikedn/68c76ebca65ce1c26e9d145eee420eb3