-
Notifications
You must be signed in to change notification settings - Fork 81
Add API disable_collection() #474
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
Conversation
wks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I think we now have two boolean states:
- "initialized" vs "uninitialized", i.e.
initialized - "enabled" vs "disabled", i.e.
trigger_gc_when_heap_is_full
Now we may have a state where is_initialized()==false but is_gc_enabled() == true. This is a bit confusing. enable_collection and disable_collection seem to be switching both Boolean variables. It is confusing, too. I think it is worth renaming those functions.
vmbindings/dummyvm/src/tests/allcoate_with_disable_collection.rs
Outdated
Show resolved
Hide resolved
Do you think it will be more clear if we separate |
I think it is worth the separation. TL;DR: My suggestion is mandating There are multiple reasons why VMs may not want "GC" to happen.
I don't think any VM would use MMTk but only ever use NoGC. Usually, a VM will allow the user to select a GC algorithm ( Among the four reasons listed above, I think only (2) is related to correctness. The VM must tell MMTk when it is okay to do GC. But I think we need to be careful here. So far, our GC algorithms only scan objects during some explicit "GC" periods (nursery GC, full GC, etc.). I suppose there are other GC algorithms that need to read GC metadata in barriers, too. Naive RC, for example, frees objects recursively after DEC-ing an object to 0. Maybe such algorithms are stupid. I don't know, but I think it is better to rename such an API function to As for (3), it is hard to classify what exactly is a "GC". Deferred RC and RC-Immix can recycle objects without even partially scanning the heap. Do MMTk developers and application programmers count that as "GC"? However, in the case of (4), it basically gives the user fine-grained control to GC details. I think this PR is to fix issue #457 which address (3), i.e. implementing Julia's enable/disable GC API. I think disabling "triggering GC when unable to acquire more pages" is good enough for Julia. For (4), we may leave that for a different PR, or maybe the researchers would prefer directly modifying the source code. For #214, why don't we do what JikesRVM MMTk does? In JikesRVM, if |
|
jikesrvm-binding-test |
|
openjdk-binding-test |
|
v8-binding-test |
wks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have four states w.r.t. initialized (VM initialzing GC) and gc_enabled (user enable/disabling GC).
initialized == false && gc_enabled == true: VM has just started. When heap is full, it should panic.initialized == true && gc_enabled == true: VM initialized GC, and is probably running app now. When heap is full, it should do GC.initialized == true && gc_enabled == false: The user explicitly disabled GC. When heap is full, it should keep allocating until running out of physical memory.initialized == false && gc_enabled == false: This state is rare, but still reachable. During VM booting process, the VM may disable GC so that it may temporarily exceed heap size. Then it initializes the collector and enables GC, and the heap shrinks back to the specified heap size. In this state, it should also keep allocating until running out of physical memory.
Another thing worth further discussion is whether we still allow user-triggered GC (System.gc() or jl_gc_collect()) when the user explicitly disabled GC.
in initialize_collection()
|
I have pushed my changes. Can you check if those changes addressed your comments and if there are other required changes? @wks |
wks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now.
This PR adds a new API call
disable_collection(), which can be used in pair withenable_collection()to temporarily allow allocating without triggering a GC. This closes #457.