-
Notifications
You must be signed in to change notification settings - Fork 1.7k
consider applying MADV_DONTNEED to snapshot data section after load #44019
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
Comments
If the memory is |
I've tried this out, and unfortunately madvise(DONTNEED) has the wrong semantics for the VM to safely use it. If the memory isn't file-backed, it will be brought back in as zeros, but we need such memory to be left resident / ignored by madvise instead. (Parts of the clustered snapshot are not read-once because of external typed data pointing into it, the embedder reusing the snapshot for other isolates, or free reading malloc metadata.) The VM isn't always passed a snapshot that is file-backed, so any madvise(DONTNEED) needs to be done in embedders when the embedder can guarantee file-backed snapshots. |
If we expose the right symbols, could we let the embedder(s) do the madvise calls for the region of RO which contains the serialized snapshot only (not the RO mapped heap objects)? |
…e snapshot. This region is mostly unused after loading, but it may be accessed again if - Isolate.spawn is invoke with isolate groups disabled - A secondary snapshot produced by splitting is loaded - An external typed data in the snapshot is accessed (usually a kernel file) - Likely other cases Even if these cases did not exist, the region is often part of a shared library and so unable to be released independently. madvise(DONT_NEED) on this region will cause the OS to release the memory in this region but keep the address space reservation and mapping. If it is touched again, it will be brought back in from the file. If it is not backed by a file, such as malloc memory, it will be brought back in as zeros and the program will likely fail. TEST=ci Bug: #44019 Bug: flutter/flutter#92120 Change-Id: I315a049b0f7d440e181d0a5e87fa6770a2fd4f79 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216580 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Siva Annamalai <[email protected]>
…e(DONTNEED). TEST=ci Bug: #44019 Change-Id: Ib717ff2123b537787929cf591e0cef7149e5292e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218064 Reviewed-by: Siva Annamalai <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
Once snapshot is unpacked into isolate memory it is likely that it will not be needed again (especially if lightweight isolates are enabled). For environments with strict memory constraints we should consider findings ways to let OS release this memory and decrease RSS.
/cc @mkustermann @rmacnak-google
The text was updated successfully, but these errors were encountered: