Relocation strategy for mscorlib.ni.dll
Testing a trivial application on Linux x64 with mscorlib.ni.dll reveals that a large amount of memory is counted as Private_Dirty after PEImageLayout::ApplyBaseRelocations() is called.
7f3dc749e000-7f3dc7a53000 rw-p 00001000 08:01 7871311 /home/wvoquine/coreclr-demo/runtime/mscorlib.ni.dll Private_Dirty: 2820 kB
7f3dc7a74000-7f3dc81ff000 r-xp 005d7000 08:01 7871311 /home/wvoquine/coreclr-demo/runtime/mscorlib.ni.dll Private_Dirty: 1012 kB
Are there any current plans to reduce the relocation impact to dirty memory?
cc @jkotas @JohnChen0
cc @janvorli @gkhanna79 Another place where not having native platform images is hurting us.
We could consider switching over to R2R image even for mscorlib to mitigate the dirty memory hit, but it will cause more JITing. @JohnChen0 Could you please take a look at this once the generic support for R2R is implemented? We should understand the startup time hit from doing so.
It looks like the problem is present only on AMD64 due to the following code in MAPMapPEFile():
#if !defined(_AMD64_)
loadedBase = mmap((void*)preferredBase, virtualSize, PROT_NONE, MAP_ANON, -1, 0);
#else // defined(_AMD64_)
// First try to reserve virtual memory using ExecutableAllcator. This allows all PE images to be
// near each other and close to the coreclr library which also allows the runtime to generate
// more efficient code (by avoiding usage of jump stubs).
loadedBase = ReserveMemoryFromExecutableAllocator(virtualSize);
if (loadedBase == NULL)
{
// MAC64 requires we pass MAP_SHARED (or MAP_PRIVATE) flags - otherwise, the call is failed.
// Refer to mmap documentation at http://www.manpagez.com/man/2/mmap/ for details.
loadedBase = mmap((void*)preferredBase, virtualSize, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
}
#endif // !defined(_AMD64_)
We will look into this post-RTM.
@jkotas should this issue still be open?