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
Speed up data dehydration #79209
Conversation
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.
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsNow 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. 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
|
src/coreclr/nativeaot/Common/src/Internal/Runtime/CompilerHelpers/StartupCodeHelpers.cs
Show resolved
Hide resolved
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
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