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

Recycle actor heap chunks after GC instead of returning to pool #4531

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dipinhora
Copy link
Contributor

Before this commit, any unused chunks after actor heap garbage collection would be destroyed and returned to the memory pool immediately for reuse by the runtime or any actor.

This commit changes things so that instead of destroying and returning the chunks immediatelly, we assume the actor will likely need more memory as it runs more behaviors and keep the recently unused chunks around in case that happens. This is generally more efficient than destroying a chunk and getting a new one from the memory pool because both destorying a chunk and allocating a new one involve updating the pagemap for the chunk to indicate which actor owns the chunk. Updating the pagemap is an expensive operation which we can avoid if we recycle the chunks instead. The main drawback is that since actors will no longer return chunks to the memory pool immediately after a GC, the overall system might end up using more memory as any freed chunks can only be reused by the actor that owns them and the runtime and other actors can no longer reuse that memory as they previously might have been able to.

Before this commit, any unused chunks after actor heap garbage
collection would be destroyed and returned to the memory pool
immediately for reuse by the runtime or any actor.

This commit changes things so that instead of destroying and
returning the chunks immediatelly, we assume the actor will likely
need more memory as it runs more behaviors and keep the recently
unused chunks around in case that happens. This is generally more
efficient than destroying a chunk and getting a new one from the
memory pool because both destorying a chunk and allocating a new
one involve updating the pagemap for the chunk to indicate which
actor owns the chunk. Updating the pagemap is an expensive operation
which we can avoid if we recycle the chunks instead. The main
drawback is that since actors will no longer return chunks to the
memory pool immediately after a GC, the overall system might end
up using more memory as any freed chunks can only be reused by the
actor that owns them and the runtime and other actors can no longer
reuse that memory as they previously might have been able to.
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss during sync Should be discussed during an upcoming sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants