Skip to content
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

[Jit] Delete Statement::m_compilerAdded . #64506

Merged
merged 1 commit into from
Feb 4, 2022

Conversation

sandreenko
Copy link
Contributor

@sandreenko sandreenko commented Jan 30, 2022

Delete Statement::m_compilerAdded field to save some memory during compilation:

--class Statement	size(56):
++class Statement	size(48):
	+---
 0	| m_rootNode
 8	| m_treeList
16	| m_next
24	| m_prev
32	| DebugInfo m_debugInfo
--48	| m_compilerAdded
--  	| <alignment member> (size=7)

and size on crossgen2 SPC:

--alloc size :   2035068447 (avg   71183 per method)
++alloc size :   2031246799 (avg   71049 per method)

around 0.2% improvement.

no diffs with jit-diff, no diff with spmi, but there are some missing data failures, because in the past we:

  1. did not mark some compiler added as compiler added;
  2. did not recognize natural loops with both pre-condition and post-condition.
SPMI example
****** START compiling Lookup`2:System.Linq.IIListProvider<System.Linq.IGrouping<TKey,TElement>>.ToArray():ref:this (MethodHash=aa8d7d85)
IL_000f  7b e7 03 00 0a    ldfld        0xA0003E7
IL_0014  0c                stloc.2
IL_0015  08                ldloc.2
IL_0016  2c 18             brfalse.s    24 (IL_0030) <- pre loop check
IL_0018  08                ldloc.2
IL_0019  7b e8 03 00 0a    ldfld        0xA0003E8
IL_001e  0c                stloc.2
IL_001f  06                ldloc.0
IL_0020  07                ldloc.1
IL_0021  08                ldloc.2
IL_0022  a2                stelem.ref
IL_0023  07                ldloc.1
IL_0024  17                ldc.i4.1
IL_0025  58                add
IL_0026  0b                stloc.1
IL_0027  08                ldloc.2
IL_0028  02                ldarg.0
IL_0029  7b e7 03 00 0a    ldfld        0xA0003E7
IL_002e  33 e8             bne.un.s     -24 (IL_0018) <- post loop check

***** BB01
STMT00003 ( 0x015[E-] ... 0x016 )
               [000019] ------------              *  JTRUE     void
               [000018] ------------              \--*  EQ        int
               [000016] ------------                 +--*  LCL_VAR   ref    V03 loc2
               [000017] ------------                 \--*  CNS_INT   ref    null

------------ BB02 [018..030) -> BB02 (cond), preds={} succs={BB03,BB02}

***** BB02
STMT00005 ( 0x018[E-] ... 0x01E )
               [000025] -A-XG-------              *  ASG       ref
               [000024] D------N----              +--*  LCL_VAR   ref    V03 loc2
               [000023] ---XG-------              \--*  FIELD     ref    hackishFieldName
               [000022] ------------                 \--*  LCL_VAR   ref    V03 loc2

***** BB02
STMT00006 ( 0x01F[E-] ... 0x022 )
               [000029] --CXG-------              *  CALL help void   HELPER.CORINFO_HELP_ARRADDR_ST
               [000026] ------------ arg0         +--*  LCL_VAR   ref    V01 loc0
               [000027] ------------ arg1         +--*  LCL_VAR   int    V02 loc1
               [000028] ------------ arg2         \--*  LCL_VAR   ref    V03 loc2

***** BB02
STMT00007 ( 0x023[E-] ... 0x026 )
               [000034] -A----------              *  ASG       int
               [000033] D------N----              +--*  LCL_VAR   int    V02 loc1
               [000032] ------------              \--*  ADD       int
               [000030] ------------                 +--*  LCL_VAR   int    V02 loc1
               [000031] ------------                 \--*  CNS_INT   int    1

***** BB02
STMT00008 ( 0x027[E-] ... 0x02E )
               [000039] ---XG-------              *  JTRUE     void
               [000038] N--XG----U--              \--*  NE        int
               [000035] ------------                 +--*  LCL_VAR   ref    V03 loc2
               [000037] ---XG-------                 \--*  FIELD     ref    hackishFieldName
               [000036] ------------                    \--*  LCL_VAR   ref    V00 this
and now we recognize such examples and determine the correct init stmt, still no diffs.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 30, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jan 30, 2022
@ghost
Copy link

ghost commented Jan 30, 2022

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

Issue Details

Delete Statement::m_compilerAdded field to save some memory during compilation:

--class Statement	size(56):
++class Statement	size(48):
	+---
 0	| m_rootNode
 8	| m_treeList
16	| m_next
24	| m_prev
32	| DebugInfo m_debugInfo
--48	| m_compilerAdded
--  	| <alignment member> (size=7)

and size on crossgen2 SPC:

--alloc size :   2035068447 (avg   71183 per method)
++alloc size :   2031246799 (avg   71049 per method)

around 0.02% improvement.

no diffs with jit-diff, no diff with spmi, but there are some missing data failures, because in the past we:

  1. did not mark some compiler added as compiler added;
  2. did not recognize natural loops with both pre-condition and post-condition.
SPMI example
****** START compiling Lookup`2:System.Linq.IIListProvider<System.Linq.IGrouping<TKey,TElement>>.ToArray():ref:this (MethodHash=aa8d7d85)
IL_000f  7b e7 03 00 0a    ldfld        0xA0003E7
IL_0014  0c                stloc.2
IL_0015  08                ldloc.2
IL_0016  2c 18             brfalse.s    24 (IL_0030) <- pre loop check
IL_0018  08                ldloc.2
IL_0019  7b e8 03 00 0a    ldfld        0xA0003E8
IL_001e  0c                stloc.2
IL_001f  06                ldloc.0
IL_0020  07                ldloc.1
IL_0021  08                ldloc.2
IL_0022  a2                stelem.ref
IL_0023  07                ldloc.1
IL_0024  17                ldc.i4.1
IL_0025  58                add
IL_0026  0b                stloc.1
IL_0027  08                ldloc.2
IL_0028  02                ldarg.0
IL_0029  7b e7 03 00 0a    ldfld        0xA0003E7
IL_002e  33 e8             bne.un.s     -24 (IL_0018) <- post loop check

***** BB01
STMT00003 ( 0x015[E-] ... 0x016 )
               [000019] ------------              *  JTRUE     void
               [000018] ------------              \--*  EQ        int
               [000016] ------------                 +--*  LCL_VAR   ref    V03 loc2
               [000017] ------------                 \--*  CNS_INT   ref    null

------------ BB02 [018..030) -> BB02 (cond), preds={} succs={BB03,BB02}

***** BB02
STMT00005 ( 0x018[E-] ... 0x01E )
               [000025] -A-XG-------              *  ASG       ref
               [000024] D------N----              +--*  LCL_VAR   ref    V03 loc2
               [000023] ---XG-------              \--*  FIELD     ref    hackishFieldName
               [000022] ------------                 \--*  LCL_VAR   ref    V03 loc2

***** BB02
STMT00006 ( 0x01F[E-] ... 0x022 )
               [000029] --CXG-------              *  CALL help void   HELPER.CORINFO_HELP_ARRADDR_ST
               [000026] ------------ arg0         +--*  LCL_VAR   ref    V01 loc0
               [000027] ------------ arg1         +--*  LCL_VAR   int    V02 loc1
               [000028] ------------ arg2         \--*  LCL_VAR   ref    V03 loc2

***** BB02
STMT00007 ( 0x023[E-] ... 0x026 )
               [000034] -A----------              *  ASG       int
               [000033] D------N----              +--*  LCL_VAR   int    V02 loc1
               [000032] ------------              \--*  ADD       int
               [000030] ------------                 +--*  LCL_VAR   int    V02 loc1
               [000031] ------------                 \--*  CNS_INT   int    1

***** BB02
STMT00008 ( 0x027[E-] ... 0x02E )
               [000039] ---XG-------              *  JTRUE     void
               [000038] N--XG----U--              \--*  NE        int
               [000035] ------------                 +--*  LCL_VAR   ref    V03 loc2
               [000037] ---XG-------                 \--*  FIELD     ref    hackishFieldName
               [000036] ------------                    \--*  LCL_VAR   ref    V00 this
and now we recognize such examples and determine the correct init stmt, still no diffs.
Author: sandreenko
Assignees: -
Labels:

area-CodeGen-coreclr, community-contribution

Milestone: -

@EgorBo
Copy link
Member

EgorBo commented Jan 30, 2022

spmi diff job reports a diff in IntelHardwareIntrinsicTest.Program:Main https://dev.azure.com/dnceng/public/_build/results?buildId=1580601&view=ms.vss-build-web.run-extensions-tab is it related?

@sandreenko
Copy link
Contributor Author

spmi diff job reports a diff in IntelHardwareIntrinsicTest.Program:Main https://dev.azure.com/dnceng/public/_build/results?buildId=1580601&view=ms.vss-build-web.run-extensions-tab is it related?

maybe, but I have not seen it locally:

SuperPMI ASM diffs
Base JIT Path: D:\Sergey\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root_base\clrjit.dll
Diff JIT Path: D:\Sergey\git\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root_diff\clrjit.dll
Using MCH files:
  D:\Sergey\git\runtime\artifacts\spmi\mch\323185e9-208a-4b35-a413-23f9aac2d5f7.windows.x64\aspnet.run.windows.x64.checked.mch
  D:\Sergey\git\runtime\artifacts\spmi\mch\323185e9-208a-4b35-a413-23f9aac2d5f7.windows.x64\benchmarks.run.windows.x64.checked.mch
  D:\Sergey\git\runtime\artifacts\spmi\mch\323185e9-208a-4b35-a413-23f9aac2d5f7.windows.x64\coreclr_tests.pmi.windows.x64.checked.mch
  D:\Sergey\git\runtime\artifacts\spmi\mch\323185e9-208a-4b35-a413-23f9aac2d5f7.windows.x64\libraries.crossgen2.windows.x64.checked.mch
  D:\Sergey\git\runtime\artifacts\spmi\mch\323185e9-208a-4b35-a413-23f9aac2d5f7.windows.x64\libraries.pmi.windows.x64.checked.mch
***
Asm diffs summary:
  No asm diffs

so I could not see the diff for this method.

I guess it is an example of a natural IL loop with pre- and postcondition that now we can recognize and do optimizations with it.

@sandreenko
Copy link
Contributor Author

@EgorBo could you please review this change?

@EgorBo EgorBo merged commit 59e643b into dotnet:main Feb 4, 2022
@EgorBo
Copy link
Member

EgorBo commented Feb 4, 2022

@EgorBo could you please review this change?

oops, sure! Thanks! 🙂

@sandreenko sandreenko deleted the deleteStmtCompilerAdded branch February 4, 2022 20:26
@ghost ghost locked as resolved and limited conversation to collaborators Mar 7, 2022
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 community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants