Skip to content

System.Private.CoreLib size regression when compiled with Crossgen2 compared to native Crossgen #45286

@trylek

Description

@trylek

As @am11 pointed out in the PR thread #44618, both Windows and Linux x64 SPC compiled with Crossgen2 is about 900K longer than Crossgen1. The statistics section of R2RDump --diff for the two libraries is as follows:

Left file:  D:\triage\SPC-size\CG1\System.Private.CoreLib.dll (9334784 B)
Right file: D:\triage\SPC-size\CG2\System.Private.CoreLib.dll (10193408 B)

 LEFT_SIZE RIGHT_SIZE       DIFF  PE sections (3 ELEMENTS)
----------------------------------------------------------
    143872     388608     244736  .data
   9163776    9769472     605696  .text
     26624      34816       8192  .reloc
   9334272   10192896     858624  

 LEFT_SIZE RIGHT_SIZE       DIFF  R2R sections (13 ELEMENTS)
------------------------------------------------------------
        23         28          5  CompilerIdentifier
       120        120             ImportSections
    368304     344532     -23772  RuntimeFunctions
    123504     220701      97197  MethodDefEntryPoints
      8848       8800        -48  ExceptionInfo
    807230     782522     -24708  DebugInfo
        33     386109     386076  DelayLoadMethodCallThunks
     11525      11525             AvailableTypes
    187472     240489      53017  InstanceMethodEntryPoints
     96140                -96140  InliningInfo
     16384      16384             AttributePresence
                  228        228  ManifestMetadata
               104880     104880  InliningInfo2
   1619583    2116318     496735  

LEFT COUNT | RIGHT COUNT | LEFT SIZE | RIGHT SIZE | R2R methods
---------------------------------------------------------------
      3173 |        --- |     221002 |        --- | LEFT METHODS
       --- |       1090 |        --- |      76176 | RIGHT METHODS
     26263 |      26263 |    2994580 |    2996609 | COMMON METHODS
     29436 |      27353 |    3215582 |    3072785 | ALL METHODS

(This includes some of my local improvements in R2RDump not yet merged in, I'll send out a separate PR for them.) According to the diff, slightly less than half of the size diff is due to the DelayLoadMethodThunks section that is vastly longer with CG2 compared to CG1. @nattress implemented the section in #39063, we need to find out why CG1 uses such a much more compact encoding - perhaps something like putting all thunks next to each other and representing them with a single interval. Also there's still more than 400K unaccounted for, I was originally thinking about methods but after improving their accounting in R2RDump it looks like the CG2 methods are actually slightly shorter than CG1.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions