Skip to content

Conversation

@amanasifkhalid
Copy link
Contributor

@amanasifkhalid amanasifkhalid commented Feb 22, 2024

Fixes #98772. Recently, we started checking successor edge likelihoods in Compiler::fgDebugCheckProfileWeights by default; this means we call Compiler::fgDebugCheckOutgoingProfileData in Debug/Checked builds to verify successor edges' likelihoods, and thus call BasicBlock::GetSucc(unsigned, Compiler*) to iterate the successor edges. For switch blocks, GetSucc(unsigned, Compiler*) calls GetSwitchDescMap, and builds m_switchDescMap if it doesn't exist yet. Upon finishing edge likelihood verification, we don't reset m_switchDescMap, so it is possible for this map to be created earlier in Debug/Checked builds versus Release builds.

This doesn't result in behavioral diffs if the map contains the same state between Debug/Release builds by the time it is read. However, if the map is null by the time it is needed, it is created on-demand, ensuring it is completely up-to-date. If the map is not null, the correctness of its current state depends on how judiciously it was maintained with UpdateSwitchTableTarget, creating potential for diffs in the map's state. By invalidating the map instead of updating it as state changes, we can force it to be rebuilt with the latest state when it's needed.

@ghost ghost assigned amanasifkhalid Feb 22, 2024
@amanasifkhalid
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-asmdiffs-checked-release

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@amanasifkhalid
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-asmdiffs-checked-release

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ryujit-bot
Copy link

Diff results for #98789

Assembly diffs

Assembly diffs for linux/arm64 ran on windows/x64

Diffs are based on 2,554,585 contexts (1,019,526 MinOpts, 1,535,059 FullOpts).

MISSED contexts: 172 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 381,315,748 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 165,778,652 +0 0.00%

Assembly diffs for linux/x64 ran on windows/x64

Diffs are based on 2,543,224 contexts (988,245 MinOpts, 1,554,979 FullOpts).

MISSED contexts: 177 (0.01%)

Overall (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 329,922,608 -3 +0.16%
FullOpts (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 147,120,622 -3 +0.16%

Assembly diffs for osx/arm64 ran on windows/x64

Diffs are based on 2,317,543 contexts (945,402 MinOpts, 1,372,141 FullOpts).

MISSED contexts: 170 (0.01%)

Overall (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 312,729,720 +12 +0.04%
FullOpts (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 111,327,984 +12 +0.04%

Assembly diffs for windows/arm64 ran on windows/x64

Diffs are based on 2,402,908 contexts (955,693 MinOpts, 1,447,215 FullOpts).

MISSED contexts: 174 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 328,693,680 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 123,601,008 +0 0.00%

Details here


Throughput diffs

Throughput diffs for linux/arm64 ran on windows/x64

MinOpts (-0.00% to +0.01%)
Collection PDIFF
libraries.pmi.linux.arm64.checked.mch +0.01%

Throughput diffs for osx/arm64 ran on windows/x64

MinOpts (-0.01% to +0.00%)
Collection PDIFF
libraries.pmi.osx.arm64.checked.mch -0.01%

Details here


@ryujit-bot
Copy link

Diff results for #98789

Assembly diffs

Assembly diffs for osx/arm64 ran on linux/x64

Diffs are based on 2,317,543 contexts (945,402 MinOpts, 1,372,141 FullOpts).

MISSED contexts: 170 (0.01%)

Overall (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 312,729,720 +12 +0.04%
FullOpts (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 111,327,984 +12 +0.04%

Assembly diffs for windows/arm64 ran on linux/x64

Diffs are based on 2,402,908 contexts (955,693 MinOpts, 1,447,215 FullOpts).

MISSED contexts: 174 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 328,693,680 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 123,601,008 +0 0.00%

Details here


@ryujit-bot
Copy link

Diff results for #98789

Assembly diffs

Assembly diffs for linux/arm64 ran on windows/x64

Diffs are based on 2,554,585 contexts (1,019,526 MinOpts, 1,535,059 FullOpts).

MISSED contexts: 172 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 381,315,748 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 165,778,652 +0 0.00%

Assembly diffs for linux/x64 ran on windows/x64

Diffs are based on 2,543,224 contexts (988,245 MinOpts, 1,554,979 FullOpts).

MISSED contexts: 177 (0.01%)

Overall (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 329,922,608 -3 +0.16%
FullOpts (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 147,120,622 -3 +0.16%

Details here


@amanasifkhalid amanasifkhalid marked this pull request as ready for review February 22, 2024 14:29
@amanasifkhalid
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-asmdiffs-checked-release

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@amanasifkhalid amanasifkhalid changed the title JIT: Invalidate m_switchDescMap after debug profile checks JIT: Invalidate m_switchDescMap instead of updating it Feb 22, 2024
if (modified)
{
// Invalidate the set of unique targets for block, since we modified the targets
InvalidateUniqueSwitchSuccMap();
Copy link
Member

@jakobbotsch jakobbotsch Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
InvalidateUniqueSwitchSuccMap();
fgInvalidateSwitchDescMapEntry(block);

? Or do we need to invalidate the full thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to work; fixed.

@amanasifkhalid
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-asmdiffs-checked-release

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@amanasifkhalid
Copy link
Contributor Author

cc @dotnet/jit-contrib for visibility.

@amanasifkhalid amanasifkhalid added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 22, 2024
@ghost
Copy link

ghost commented Feb 22, 2024

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #98772. Recently, we started checking successor edge likelihoods in Compiler::fgDebugCheckProfileWeights by default; this means we call Compiler::fgDebugCheckOutgoingProfileData in Debug/Checked builds to verify successor edges' likelihoods, and thus call BasicBlock::GetSucc(unsigned, Compiler*) to iterate the successor edges. For switch blocks, GetSucc(unsigned, Compiler*) calls GetSwitchDescMap, and builds m_switchDescMap if it doesn't exist yet. Upon finishing edge likelihood verification, we don't reset m_switchDescMap, so it is possible for this map to be created earlier in Debug/Checked builds versus Release builds.

This doesn't result in behavioral diffs if the map contains the same state between Debug/Release builds by the time it is read. However, if the map is null by the time it is needed, it is created on-demand, ensuring it is completely up-to-date. If the map is not null, the correctness of its current state depends on how judiciously it was maintained with UpdateSwitchTableTarget, creating potential for diffs in the map's state. By invalidating the map instead of updating it as state changes, we can force it to be rebuilt with the latest state when it's needed.

Author: amanasifkhalid
Assignees: amanasifkhalid
Labels:

area-CodeGen-coreclr

Milestone: -

@ryujit-bot
Copy link

Diff results for #98789

Assembly diffs

Assembly diffs for linux/arm64 ran on windows/x64

Diffs are based on 2,554,585 contexts (1,019,526 MinOpts, 1,535,059 FullOpts).

MISSED contexts: 172 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 381,315,748 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 165,778,652 +0 0.00%

Assembly diffs for linux/x64 ran on windows/x64

Diffs are based on 2,543,224 contexts (988,245 MinOpts, 1,554,979 FullOpts).

MISSED contexts: 177 (0.01%)

Overall (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 329,922,608 -3 +0.16%
FullOpts (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 147,120,622 -3 +0.16%

Assembly diffs for osx/arm64 ran on windows/x64

Diffs are based on 2,317,543 contexts (945,402 MinOpts, 1,372,141 FullOpts).

MISSED contexts: 170 (0.01%)

Overall (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 312,729,720 +12 +0.04%
FullOpts (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 111,327,984 +12 +0.04%

Assembly diffs for windows/arm64 ran on windows/x64

Diffs are based on 2,402,908 contexts (955,693 MinOpts, 1,447,215 FullOpts).

MISSED contexts: 174 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 328,693,680 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 123,601,008 +0 0.00%

Details here


Throughput diffs

Throughput diffs for osx/arm64 ran on windows/x64

MinOpts (-0.01% to +0.00%)
Collection PDIFF
libraries.pmi.osx.arm64.checked.mch -0.01%

Throughput diffs for windows/arm64 ran on windows/x64

MinOpts (-0.01% to +0.00%)
Collection PDIFF
libraries.pmi.windows.arm64.checked.mch -0.01%

Details here


@ryujit-bot
Copy link

Diff results for #98789

Assembly diffs

Assembly diffs for osx/arm64 ran on linux/x64

Diffs are based on 2,317,543 contexts (945,402 MinOpts, 1,372,141 FullOpts).

MISSED contexts: 170 (0.01%)

Overall (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 312,729,720 +12 +0.04%
FullOpts (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 111,327,984 +12 +0.04%

Assembly diffs for windows/arm64 ran on linux/x64

Diffs are based on 2,402,908 contexts (955,693 MinOpts, 1,447,215 FullOpts).

MISSED contexts: 174 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 328,693,680 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 123,601,008 +0 0.00%

Details here


Throughput diffs

Throughput diffs for linux/arm64 ran on windows/x64

MinOpts (-0.01% to +0.00%)
Collection PDIFF
libraries.pmi.linux.arm64.checked.mch -0.01%

Details here


@amanasifkhalid
Copy link
Contributor Author

runtime-coreclr superpmi-asmdiffs-checked-release passed.

@amanasifkhalid amanasifkhalid merged commit c86ab13 into dotnet:main Feb 22, 2024
@amanasifkhalid amanasifkhalid deleted the switch-maintenance branch February 22, 2024 19:10
@ryujit-bot
Copy link

Diff results for #98789

Assembly diffs

Assembly diffs for linux/arm64 ran on windows/x64

Diffs are based on 2,554,585 contexts (1,019,526 MinOpts, 1,535,059 FullOpts).

MISSED contexts: 172 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 381,315,748 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.arm64.Release.mch 165,778,652 +0 0.00%

Assembly diffs for linux/x64 ran on windows/x64

Diffs are based on 2,543,224 contexts (988,245 MinOpts, 1,554,979 FullOpts).

MISSED contexts: 177 (0.01%)

Overall (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 329,922,608 -3 +0.16%
FullOpts (-3 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.linux.x64.Release.mch 147,120,622 -3 +0.16%

Assembly diffs for osx/arm64 ran on windows/x64

Diffs are based on 2,317,543 contexts (945,402 MinOpts, 1,372,141 FullOpts).

MISSED contexts: 170 (0.01%)

Overall (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 312,729,720 +12 +0.04%
FullOpts (+12 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.osx.arm64.Release.mch 111,327,984 +12 +0.04%

Assembly diffs for windows/arm64 ran on windows/x64

Diffs are based on 2,402,908 contexts (955,693 MinOpts, 1,447,215 FullOpts).

MISSED contexts: 174 (0.01%)

Overall (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 328,693,680 +0 0.00%
FullOpts (+0 bytes)
Collection Base size (bytes) Diff size (bytes) PerfScore in Diffs
libraries_tests.run.windows.arm64.Release.mch 123,601,008 +0 0.00%

Details here


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diff in checked vs. release

3 participants