-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Garbage collect only when all isolates are idle #72031
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 8000 “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
Some additional thoughts here - NotifyIdle does not necessarily force a collection, especially if the deadline is short. However, if it does, there's no guarantee that the collection will happen in that timespan, particularly if a heap compaction is required. It's not abnormal to see a 200-400ms compaction happen in parallel to other work. If notify idle was called again during this time, I'm pretty sure it wouldn't really matter - the GC is already running. But we already have some issue with a single isolate where the GC threads run at the same priority as the rendering threads, and you get scheduling contention that can cause jank. |
There's no guarantee, but the VM makes an estimate how long e.g. a compaction would take - and might decide not to do if the given idle time is not enough. The intent here is to change the idle notification in engine to only trigger after all UI isolates are idle (e.g. have drawn their frame). The idle deadline used would be until the timepoint when the first UI isolate has more work to do. -> So this wouldn't apply to all isolates, just UI isolates. |
My data set is small, but the traces I've seen where compaction happens it routinely takes multiple frames (e.g. 200+ ms) to complete. So what I'll see is something like this:
Lowering the priority of the VM threads relative to the UI/Raster thread should probably help that kind of issue, but it makes it seem moot to me whether all UI isolates have finished or not. |
@dnfield You can find the VM's estimation logic here. If it significantly overshoots the idle deadline, maybe the estimate the VM makes needs to be adjusted. /cc @rmacnak-google |
Let me put it this way: I have not seen a trace where a compaction happens within a single frame (16ms), let alone within the deadline. But it's also entirely possible that I see it lining up with NotifyIdle coincidentally, and the VM has just decided "too bad I need to compact anyway now." |
We're currently signaling the Dart garbage collector to collect when the animator/engine is notifying idle. To avoid one isolate signaling idle and causing a garbage collection which would jank another rendering isolate, alter the logic to let the garbage collection only occur when all isolates are idle.
#71253 partly related.
The text was updated successfully, but these errors were encountered: