This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Support memory decommission of instance memory on macOS #9164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the memory decommission support for macOS that was added for Linux in #8998.
While we don't support running validators on macOS and thus performance is less of a concern we should still aim for feature parity on all systems we support. Otherwise we might run in situations where development on those plattforms will be impeded by high resource consumption or other inconveniences. This can be a slippery slope that can eventually lead to having Linux as the de facto exclusive platform.
Supporting this on macOS is more involved because the
madvise
API won't work there to remove memory from the resident set. One has to use the low levelmach_*
interfaces. The memory needs to be allocated in a specific way so that the kernel can track it for decommission. In addition we need to work around some old TODO that limits purgeable memory mappings to 32bit. I filed a radar for that.I did the following in order to implement this feature:
mach_allocate
by implementing theMemoryCreator
trait of wasmtimepurge
in mach lingo) the memory when the instance is put back into the cache