Skip to content

CodeVersionManager updates - #102298

Merged
AaronRobinsonMSFT merged 8 commits into
dotnet:mainfrom
AaronRobinsonMSFT:codeversion_updates
May 22, 2024
Merged

AaronRobinsonMSFT merged 8 commits into
dotnet:mainfrom
AaronRobinsonMSFT:codeversion_updates

Conversation

@AaronRobinsonMSFT

@AaronRobinsonMSFT AaronRobinsonMSFT commented May 16, 2024 •

Copy link
Copy Markdown
Member

Remove maps on CodeVersionManager and places native version data on the MethodDesc and the IL version data on the Module. There is no functional change intended here. The change is simply to remove two currently unnecessary map data structures. The contract API has change slightly but remains semantically the same.

This is a simplification for the cDAC effort.

Remove the dictionary from the CodeVersionManager
and instead store the data directly on the MethodDesc.

Pass allocator for codedata allocation.
Move the state data structure to typical MethodDesc instance.
@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

/cc @elinor-fung @lambdageek

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

No regressions found running the diagnostic tests locally with this change.

Comment thread src/coreclr/vm/method.hpp Resolved

@davidwrighton davidwrighton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good, but as I discussed offline, before you checkin, I'd like to know what the impact is on memory consumption.

@AaronRobinsonMSFT

Copy link
Copy Markdown
Member Author

I used https://github.com/dotnet/eShop to collect memory usage numbers. I focused on the Catalog service.

Overall runtime memory consumption increased by 811k with these changes. The complexity reduction for the cDAC is a substantial and @davidwrighton is working on using this new data hanging off the MethodDesc to further claw back some of this memory increase.

Main:

0:016> !eeheap
Loader Heap:
----------------------------------------
...
Total size:           Size: 0xee6000 (15622144) bytes total, 0x6f000 (454656) bytes wasted.
----------------------------------------
...
----------------------------------------
JIT Manager:          01f03ea3de60
LoaderCodeHeap:       7ffeabb60000(80000:49000) Size: 0x49000 (299008) bytes total.
LoaderCodeHeap:       7ffeac790000(80000:30000) Size: 0x30000 (196608) bytes total.
HostCodeHeap:         7ffeabe00000(2000:2000) Size: 0x2000 (8192) bytes total.
Total size:           Size: 0x7b000 (503808) bytes total.
----------------------------------------
...
------------------------------
GC Allocated Heap Size:    Size: 0xfd9910 (16619792) bytes.
GC Committed Heap Size:    Size: 0x1679000 (23564288) bytes.

Total bytes consumed by CLR: 0x25da000 (39690240)

0:016> !heap -s


************************************************************************************************************************
                                              NT HEAP STATS BELOW
************************************************************************************************************************
LFH Key                   : 0xc67164fed3c3c0e1
Termination on corruption : ENABLED
Affinity manager status:
   - Virtual affinity limit 32
   - Current entries in use 0
   - Statistics:  Swaps=0, Resets=0, Allocs=0

          Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast 
                            (k)     (k)    (k)     (k) length      blocks cont. heap 
-------------------------------------------------------------------------------------
000001f03e9d0000 00000002    8956   6584   8176   1343   145     4    0      4   LFH
    External fragmentation  20 % (145 free blocks)
000001f03e780000 00008000      64      4     64      2     1     1    0      0      
000001f03ecb0000 00001002     840     68     60     17     3     1    0      0   LFH
000001f040590000 00001002      60      8     60      2     1     1    0      0      
000001f03e9b0000 00041002      60      8     60      5     1     1    0      0      
000001f002ba0000 00001002    1080    292   1080    289     2     2    0      0      
-------------------------------------------------------------------------------------

With changes:

0:016> !eeheap
Loader Heap:
----------------------------------------
...
Total size:           Size: 0xfab000 (16429056) bytes total, 0x71000 (462848) bytes wasted.
----------------------------------------
...
----------------------------------------
JIT Manager:          01eac647e070
LoaderCodeHeap:       7fff342a0000(80000:4a000) Size: 0x4a000 (303104) bytes total.
LoaderCodeHeap:       7fff34f60000(80000:30000) Size: 0x30000 (196608) bytes total.
HostCodeHeap:         7fff34560000(2000:2000) Size: 0x2000 (8192) bytes total.
Total size:           Size: 0x7c000 (507904) bytes total.
----------------------------------------
...
------------------------------
GC Allocated Heap Size:    Size: 0xfdff60 (16645984) bytes.
GC Committed Heap Size:    Size: 0x1679000 (23564288) bytes.

Total bytes consumed by CLR: 0x26a0000 (40501248)

0:016> !heap -s


************************************************************************************************************************
                                              NT HEAP STATS BELOW
************************************************************************************************************************
LFH Key                   : 0x84a86b077d3aa5e7
Termination on corruption : ENABLED
Affinity manager status:
   - Virtual affinity limit 32
   - Current entries in use 0
   - Statistics:  Swaps=0, Resets=0, Allocs=0

          Heap     Flags   Reserv  Commit  Virt   Free  List   UCR  Virt  Lock  Fast 
                            (k)     (k)    (k)     (k) length      blocks cont. heap 
-------------------------------------------------------------------------------------
000001eac6410000 00000002    8956   6420   8176    993   145     4    0      5   LFH
    External fragmentation  15 % (145 free blocks)
000001eac6280000 00008000      64      4     64      2     1     1    0      0      
000001eac6740000 00001002     840     68     60     17     3     1    0      0   LFH
000001eac8060000 00001002      60      8     60      2     1     1    0      0      
000001eac8030000 00041002      60      8     60      5     1     1    0      0      
000001ea82a80000 00001002    1080    292   1080    289     2     2    0      0      
-------------------------------------------------------------------------------------

@davidwrighton davidwrighton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use the NoThrow variant of the allocator

Comment thread src/coreclr/vm/method.cpp Resolved
@davidwrighton

Copy link
Copy Markdown
Member

Great, now to integrate this with #101580

@AaronRobinsonMSFT
AaronRobinsonMSFT merged commit b8f554d into dotnet:main May 22, 2024
@AaronRobinsonMSFT
AaronRobinsonMSFT deleted the codeversion_updates branch May 22, 2024 02:15
steveharter pushed a commit to steveharter/runtime that referenced this pull request May 28, 2024
* Code Versioning - move native code versioning state

Remove the dictionary from the CodeVersionManager
and instead store the data directly on the MethodDesc.

* Remove dictionary for IL version states.

Remove the dictionary from the CodeVersionManager
and instead store the data in the Module.
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
* Code Versioning - move native code versioning state

Remove the dictionary from the CodeVersionManager
and instead store the data directly on the MethodDesc.

* Remove dictionary for IL version states.

Remove the dictionary from the CodeVersionManager
and instead store the data in the Module.
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants