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

memory decommit does not work with large pages #914

Open
romange opened this issue Jul 9, 2024 · 2 comments
Open

memory decommit does not work with large pages #914

romange opened this issue Jul 9, 2024 · 2 comments

Comments

@romange
Copy link
Contributor

romange commented Jul 9, 2024

Seems that mimalloc does not decommit memory that was comitted using large pages. See

if (arena->memid.is_pinned || arena->blocks_purge == NULL) return false;

and

memid.is_pinned = is_large;

what's the motivation behind this? why large pages can not be decomitted?

@daanx
Copy link
Collaborator

daanx commented Aug 13, 2024

Ah, on Windows, large OS pages (2Mib) (called huge pages on Linux), or huge OS pages (1GiB) are "pinned" in memory and cannot be de-committed. In particular huge OS pages are always mapped to physical memory and cannot be shared between processes for example (which I why you generally need to give permission on Windows for processes to "lock" memory).

Maybe this is too restrictive though since on Linux these restrictions may not hold (in particular since we "decommit" on Linux by using mprotect with PROT_NONE).

@romange
Copy link
Contributor Author

romange commented Aug 14, 2024

Yes, for long running processes like dragonfly we would like to have some kind of control over the RSS usage. We have even implemented a special administrative command that calls mi_heap_collect for all the heaps in the system. It gives us confidence that Dragonfly itself does not leak memory and all the memory is accountable.

Another issue that we see when using large pages (2MB) is that the RSS usage for a long-running process can constantly grow for some usage patterns: the gap between RSS and sum(heap){mi_heap_visit_blocks(heap)} widens with time. We took a decision to stop using large 2MB pages recently, and we see that the memory usage of our servers became more stable now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants