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

Speed up data dehydration #79209

Merged
merged 1 commit into from Dec 5, 2022
Merged

Speed up data dehydration #79209

merged 1 commit into from Dec 5, 2022

Conversation

MichalStrehovsky
Copy link
Member

Now that we switched everything we wanted to switch to dehydrated data, I redid startup measurements.

I used a 30 MB app that doesn't actually do anything useful with those megabytes and just exits (to get a lot of dehydrated data into the startup path).

On Windows:

(The measurements were frustratingly noisy within a range that spans 10 ms.)

Without dehydration, the app exits in ~27 ms.
With dehydration, the app exits in ~37 ms.
With the fixes in this PR and dehydration, it exits in ~34 ms.

On Linux, the difference between not dehydrated and dehydrated is ~8 ms -> ~12 ms. I didn't re-measure with this PR. Possibly shaved off a millisecond.

Cc @dotnet/ilc-contrib

Now that we switched everything we wanted to switch to dehydrated data, I redid startup measurements.

I used a 30 MB app that doesn't actually do anything useful with those megabytes and just exits (to get a lot of dehydrated data into the startup path).

On Windows:

(The measurements were frustratingly noisy within a range that spans 10 ms.)

Without dehydration, the app exits in ~27 ms.
With dehydration, the app exits in ~37 ms.
With the fixes in this PR and dehydration, it exits in ~34 ms.

On Linux, the difference between not dehydrated and dehydrated is ~8 ms -> ~12 ms. I didn't re-measure with this PR. Possibly shaved off a millisecond.
@ghost
Copy link

ghost commented Dec 5, 2022

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

Issue Details

Now that we switched everything we wanted to switch to dehydrated data, I redid startup measurements.

I used a 30 MB app that doesn't actually do anything useful with those megabytes and just exits (to get a lot of dehydrated data into the startup path).

On Windows:

(The measurements were frustratingly noisy within a range that spans 10 ms.)

Without dehydration, the app exits in ~27 ms.
With dehydration, the app exits in ~37 ms.
With the fixes in this PR and dehydration, it exits in ~34 ms.

On Linux, the difference between not dehydrated and dehydrated is ~8 ms -> ~12 ms. I didn't re-measure with this PR. Possibly shaved off a millisecond.

Cc @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@ghost ghost assigned MichalStrehovsky Dec 5, 2022
Copy link
Member

@VSadov VSadov left a comment

Choose a reason for hiding this comment

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

LGTM

for (; payload > 0; payload--)
*pDest++ = *pCurrent++;
Debug.Assert(payload != 0);
if (payload < 4)
Copy link
Member

Choose a reason for hiding this comment

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

Does it regress if we use:

// > 64 hits p/invoke: https://github.com/dotnet/runtime/blob/5f51269/src/libraries/System.Private.CoreLib/src/System/Buffer.cs#L145
if (payload <= 64)
{
    Buffer.MemoryCopy(pDest, pCurrent, payload, payload);
}
else // existing code to avoid p/invoke - line 289 onwards

Copy link
Member Author

Choose a reason for hiding this comment

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

It won't compile when this file is included from Test.CoreLib.csproj.

MemoryCopy is also so big it won't inline and we run this logic this tens of thousands of times in this tight loop (11k just for hello world). Inlining it is preferable.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Nice!

@jkotas jkotas merged commit 9c3134e into dotnet:main Dec 5, 2022
@MichalStrehovsky MichalStrehovsky deleted the dehfast branch December 5, 2022 20:50
@dotnet dotnet locked as resolved and limited conversation to collaborators Jan 5, 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.

None yet

5 participants