Current the block freeing thread wakes up once a second to check if there are any blocks for it to release back to the OS. This is wasteful. We should change it to sleep when it realizes there are no more blocks to free. Any thread that returns a block to the BlockAllocator should then notify the block freeing thread that there is more work to do now.
Created attachment 166562 [details] Patch
Comment on attachment 166562 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166562&action=review This fix looks correct, but I think it can get better. > Source/JavaScriptCore/heap/BlockAllocator.h:111 > + m_numberOfFreeBlocks++; Can we just use m_numberOfFreeBlocks != 0, instead of a separate m_blocksNeedFreeing boolean, to tell if we need to free anything? > Source/JavaScriptCore/heap/BlockAllocator.h:118 > + MutexLocker mutexLocker(m_freeBlockConditionLock); > + if (!m_blocksNeedFreeing) { > + m_blocksNeedFreeing = true; > + m_freeBlockCondition.signal(); > + } Rather than doing this unconditionally, I'd prefer to see this done only if m_numberOfFreeBlocks was 0 when we acquired the lock.
Created attachment 166587 [details] Patch
Comment on attachment 166587 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166587&action=review r=me > Source/JavaScriptCore/heap/BlockAllocator.h:115 > + MutexLocker mutexLocker(m_freeBlockConditionLock); > + if (!numberOfFreeBlocks) "mutexLocker" should be scoped inside "if (!numberOfFreeBlocks)", so we only acquire the mutex on the transition from zero to non-zero. Please make this change before landing.
Committed r130212: <http://trac.webkit.org/changeset/130212>
<rdar://problem/12350667>
*** Bug 90622 has been marked as a duplicate of this bug. ***
Reopening because this wasn't completely fixed.
Created attachment 169199 [details] Patch
Comment on attachment 169199 [details] Patch r=me
Comment on attachment 169199 [details] Patch Clearing flags on attachment: 169199 Committed r131619: <http://trac.webkit.org/changeset/131619>
All reviewed patches have been landed. Closing bug.