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

Jettison vxsort support in the GC when optimizing for size #85036

Merged
merged 2 commits into from
Apr 21, 2023

Conversation

MichalStrehovsky
Copy link
Member

Vxsort comes with precomputed tables that are more than 100 kB in size.

Jettison them when optimizing for size. Selfcontained hello world with optimize for size + invariant globalization is now 1.08 MB (a 10% saving).

Fixes #84749.

Cc @dotnet/ilc-contrib @dotnet/gc

Vxsort comes with precomputed tables that are more than 100 kB in size.

Jettison them when optimizing for size. Hello world with optimize for size + invariant globalization is now 1.08 MB.

Fixes dotnet#84749.
@ghost
Copy link

ghost commented Apr 19, 2023

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

Issue Details

Vxsort comes with precomputed tables that are more than 100 kB in size.

Jettison them when optimizing for size. Selfcontained hello world with optimize for size + invariant globalization is now 1.08 MB (a 10% saving).

Fixes #84749.

Cc @dotnet/ilc-contrib @dotnet/gc

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@@ -22,6 +22,8 @@ The .NET Foundation licenses this file to you under the MIT license.
<FullRuntimeName Condition="'$(ServerGarbageCollection)' == 'true' or '$(ControlFlowGuard)' == 'Guard'">Runtime.ServerGC</FullRuntimeName>
<BootstrapperName>bootstrapper</BootstrapperName>
<BootstrapperName Condition="'$(NativeLib)' != '' or '$(CustomNativeMain)' == 'true'">bootstrapperdll</BootstrapperName>
<VxSortSupportName>Runtime.VxsortSupport</VxSortSupportName>
Copy link
Member

Choose a reason for hiding this comment

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

We use -enabled / -disabled suffixes for eventpipe a few lines down. Can we use the similar pattern here?

@jkotas
Copy link
Member

jkotas commented Apr 19, 2023

Build breaks on arm64

@Maoni0
Copy link
Member

Maoni0 commented Apr 19, 2023

"in the GC" in general or only when it's compiled for WKS GC?

how does one get these disabled by default things enabled in NativeAoT? is there a page that explains that?

@MichalStrehovsky
Copy link
Member Author

"in the GC" in general or only when it's compiled for WKS GC?

In general, both server and wks GC.

Note that will be done only when the user says they're willing to trade throughput for size (i.e. it will require a gesture from the user that spells out optimization preference is size). Disabled VXSORT will not be the default.

how does one get these disabled by default things enabled in NativeAoT? is there a page that explains that?

There will be a doc page on the optimization preference setting, but it will probably not document the exact mechanism. It will only say we'll do whatever's reasonable to get size down at the cost of throughput. E.g. we align method bodies differently with this setting as well.

@cshung
Copy link
Member

cshung commented Apr 19, 2023

Instead of just turning it off, can we build the table at runtime (maybe after startup, outside of GC pause) instead?

@jkotas
Copy link
Member

jkotas commented Apr 19, 2023

Instead of just turning it off, can we build the table at runtime (maybe after startup, outside of GC pause) instead?

IIRC, the vxsort static footprint is dominated by code. The supporting data tables are relatively small.

@VSadov
Copy link
Member

VSadov commented Apr 20, 2023

If I need a server GC, since I expect lots of concurrency and some short-lived allocations, but overall do not expect an enormous heap, then I can pass IlcDisableVxsort=true?

It looks so from the change, but a bit hard to follow, - the 100 kB of vxsort stuff will not even be linked into the app, right?

@MichalStrehovsky
Copy link
Member Author

If I need a server GC, since I expect lots of concurrency and some short-lived allocations, but overall do not expect an enormous heap, then I can pass IlcDisableVxsort=true?

This change doesn't depend on whether we're building with server/workstation GC. That approach was rejected based on discussion in #84749.

We key off of two things: are we optimizing for size? (the (planned to be) publicly documented switch), or someone specified IlcDisableVxsort (undocumented switch).

Then there's a bunch of extra conditions because vxsort only works on x64 Windows and bifurcating the build further based on whether control flow guard is enabled on not didn't seem worth it so we don't disable it if control flow guard is enabled.

@MichalStrehovsky MichalStrehovsky merged commit 6b7292c into dotnet:main Apr 21, 2023
@MichalStrehovsky MichalStrehovsky deleted the vxsort branch April 21, 2023 00:49
@ghost ghost locked as resolved and limited conversation to collaborators May 21, 2023
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.

Is vxsort with workstation GC a common scenario?
5 participants