-
Notifications
You must be signed in to change notification settings - Fork 1.6k
WeakSet should count its heap allocations #47275
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
base: main
Are you sure you want to change the base?
WeakSet should count its heap allocations #47275
Conversation
EWS run on previous version of this PR (hash 310c8b8) |
@@ -41,6 +41,7 @@ inline WeakImpl* WeakSet::allocate(JSValue jsValue, WeakHandleOwner* weakHandleO | |||
weakSet.m_allocator = allocator->next; | |||
|
|||
WeakImpl* weakImpl = WeakBlock::asWeakImpl(allocator); | |||
container.vm().heap.didAllocate(sizeof(WeakImpl)); |
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.
Maybe didAllocateInBlock needs to be called to ensure the weak impl doesn't continue to appear in the weak block? (i'm just guessing at why its all red)
m_directory->markedSpace().didAllocateInBlock(m_currentBlock); |
WebKit/Source/JavaScriptCore/heap/MarkedSpace.cpp
Lines 557 to 563 in f1f86af
void MarkedSpace::didAllocateInBlock(MarkedBlock::Handle* block) | |
{ | |
if (block->weakSet().isOnList()) { | |
block->weakSet().remove(); | |
m_newActiveWeakSets.append(&block->weakSet()); | |
} | |
} |
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.
Maybe I am reading this wrong. My understanding is that didAllocateInBlock is used to make sure that weak sets get updated. That is, if I allocate Foo, then didAllocateInBlock finds any WeakSets containing Foo, and clears them. This is allocating the WeakSet itself, so we don't need didAllocateInBlock. didAllocate is just for tracking the number of newly allocated bytes, but since this file is inlinable, it can be included from other compilation units, and thus we need to export it. Let's see what a second round of EWS thinks, to see if the failures were a random fluke or caused by this patch.
https://bugs.webkit.org/show_bug.cgi?id=295072 Reviewed by NOBODY (OOPS!). Long running pages that do not allocate, but have a RAF callback can see their memory usage slowly increase forever. This is caused by WeakBlock allocations. Without other kinds of allocations, the collector thinks that the footprint isn't growing. We notify the collector about these allocations now. Notably, it is very important that we do not GC while allocating a Weak<T>, because we construct them all over the place in the middle of inserting into WeakMap. `didAllocate` does not trigger GC on its own, so this patch does not change this behaviour.
310c8b8
to
a0b8580
Compare
EWS run on current version of this PR (hash a0b8580) |
310c8b8
a0b8580