Code-Review | +1 |
}
From my understanding, the callback is invoked from here: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=1635;drc=bd4cbddbef633d3b78f3a63c8ab90e098b799a32 The `v8::GCCallbackFlags` does not include the `kLastResort` flag from `current_gc_flags_` (https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=1621;drc=bd4cbddbef633d3b78f3a63c8ab90e098b799a32), which would be important to have to know that we're in a last resort GC? It seems that `kGCCallbackFlagCollectAllAvailableGarbage` is set in CollectGarbageOnMemoryPressure() (invoked *not* on memory pressure - not a good reason to invoke memory clients), Heap::HandleExternalMemoryInterrupt() (would be a good place to tell memory clients to release external memory), but it's not set in other places that could be last resort GCs?
Extra context/question for @mlip...@chromium.org: Blink caches strong references to BlinkGC objects (example: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/memory_cache.h;l=216;drc=b225f5b0974d6e411de16c081d1f95ef7d674278). We can release these strong references, if we're told that an OOM may be declared otherwise. Is kLastResort the right flag to watch for that? (it doesn't seem to be plumbed currently, we would need to do that https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/memory_cache.h;l=216;drc=b225f5b0974d6e411de16c081d1f95ef7d674278)
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
raw_ref<ChildMemoryConsumerRegistry> registry_;
Maybe explain the lifetime here (or at least in the constructor overload)
// notify consumers that retains references to the v8 heap.
Very minor grammar nit: "retain"
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
From my understanding, the callback is invoked from here: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=1635;drc=bd4cbddbef633d3b78f3a63c8ab90e098b799a32 The `v8::GCCallbackFlags` does not include the `kLastResort` flag from `current_gc_flags_` (https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=1621;drc=bd4cbddbef633d3b78f3a63c8ab90e098b799a32), which would be important to have to know that we're in a last resort GC? It seems that `kGCCallbackFlagCollectAllAvailableGarbage` is set in CollectGarbageOnMemoryPressure() (invoked *not* on memory pressure - not a good reason to invoke memory clients), Heap::HandleExternalMemoryInterrupt() (would be a good place to tell memory clients to release external memory), but it's not set in other places that could be last resort GCs?
Extra context/question for @mlip...@chromium.org: Blink caches strong references to BlinkGC objects (example: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/memory_cache.h;l=216;drc=b225f5b0974d6e411de16c081d1f95ef7d674278). We can release these strong references, if we're told that an OOM may be declared otherwise. Is kLastResort the right flag to watch for that? (it doesn't seem to be plumbed currently, we would need to do that https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/memory_cache.h;l=216;drc=b225f5b0974d6e411de16c081d1f95ef7d674278)
Hey, I haved added the "last resort" flag in this CL [0] here. So once that CL got rolled into Chromium you should be able to use it. Note that kGCCallbackFlagCollectAllAvailableGarbage is set as well on last resort GCs but is also used in non-"last resort"-GCs as well. So I suppose it would be better here to check for that new flag and only flush this cache on "last resort"-GCs.
0: https://chromium-review.googlesource.com/c/v8/v8/+/6988487
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
LGTM w/nits and once @mlip...@chromium.org is happy
Done
Thanks. I'll wait for the v8 cl to get rolled into chromium to submit
raw_ref<ChildMemoryConsumerRegistry> registry_;
Maybe explain the lifetime here (or at least in the constructor overload)
Done
// notify consumers that retains references to the v8 heap.
Very minor grammar nit: "retain"
Done
v8::GCType gc_type,
Patrick MonetteI think you also need to filter for `GCType::kGCTypeMarkSweepCompact` here as we also emit the signal for other types and you may receive it a few times otherwise.
I've gone with not looking at `gc_type`, and checking the last resort flag instead.
Dominik InführFrom my understanding, the callback is invoked from here: https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=1635;drc=bd4cbddbef633d3b78f3a63c8ab90e098b799a32 The `v8::GCCallbackFlags` does not include the `kLastResort` flag from `current_gc_flags_` (https://source.chromium.org/chromium/chromium/src/+/main:v8/src/heap/heap.cc;l=1621;drc=bd4cbddbef633d3b78f3a63c8ab90e098b799a32), which would be important to have to know that we're in a last resort GC? It seems that `kGCCallbackFlagCollectAllAvailableGarbage` is set in CollectGarbageOnMemoryPressure() (invoked *not* on memory pressure - not a good reason to invoke memory clients), Heap::HandleExternalMemoryInterrupt() (would be a good place to tell memory clients to release external memory), but it's not set in other places that could be last resort GCs?
Extra context/question for @mlip...@chromium.org: Blink caches strong references to BlinkGC objects (example: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/memory_cache.h;l=216;drc=b225f5b0974d6e411de16c081d1f95ef7d674278). We can release these strong references, if we're told that an OOM may be declared otherwise. Is kLastResort the right flag to watch for that? (it doesn't seem to be plumbed currently, we would need to do that https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/memory_cache.h;l=216;drc=b225f5b0974d6e411de16c081d1f95ef7d674278)
Hey, I haved added the "last resort" flag in this CL [0] here. So once that CL got rolled into Chromium you should be able to use it. Note that kGCCallbackFlagCollectAllAvailableGarbage is set as well on last resort GCs but is also used in non-"last resort"-GCs as well. So I suppose it would be better here to check for that new flag and only flush this cache on "last resort"-GCs.
0: https://chromium-review.googlesource.com/c/v8/v8/+/6988487
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
13 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: third_party/blink/renderer/controller/memory_coordinator/v8_heap_memory_signal_generator.cc
Insertions: 1, Deletions: 1.
@@ -14,7 +14,7 @@
void OnV8HeapLastResortGC(v8::Isolate* isolate,
v8::GCType gc_type,
v8::GCCallbackFlags flags) {
- if (flags & v8::kGCCallbackFlagCollectAllAvailableGarbage) {
+ if (flags & v8::kGCCallbackFlagLastResort) {
blink::Platform::Current()->OnV8HeapLastResortGC();
}
}
```
```
The name of the file: content/renderer/memory_coordinator/renderer_memory_coordinator_policy.h
Insertions: 1, Deletions: 0.
@@ -36,6 +36,7 @@
private:
void OnRestoreLimitTimerFired();
+ // The registry outlives `this`.
raw_ref<ChildMemoryConsumerRegistry> registry_;
base::OneShotTimer restore_limit_timer_;
```
```
The name of the file: content/renderer/memory_coordinator/renderer_memory_coordinator_policy.cc
Insertions: 1, Deletions: 1.
@@ -46,7 +46,7 @@
}
// The V8 heap is full and can't free enough memory. To help the impending GC,
- // notify consumers that retains references to the v8 heap.
+ // notify consumers that retain references to the v8 heap.
for (auto& consumer_info : *registry_) {
if (consumer_info.traits.release_gc_references ==
base::MemoryConsumerTraits::ReleaseGCReferences::kYes) {
```
[Memory Coordinator] Add renderer policy using V8 last resort GC
This CL adds a renderer-only policy that notifies relevant
base::MemoryConsumers when V8 is running its last resort GC.
This will be used in a follow-up CL to clear strong references in the
MemoryCache, to reduce the number of OOMs.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |