Commit 3ea87598 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

Block freeing thread should sleep indefinitely when there's no work to do

https://bugs.webkit.org/show_bug.cgi?id=98084

Reviewed by Geoffrey Garen.

r130212 didn't fully fix the problem.

* heap/BlockAllocator.cpp:
(JSC::BlockAllocator::blockFreeingThreadMain): We would just continue to the next iteration if
we found that we had zero blocks to copy. We should move the indefinite wait up to where that
check is done so that we properly detect the "no more blocks to copy, wait for more" condition.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 24e4717c
2012-10-17 Mark Hahnenberg <mhahnenberg@apple.com>
Block freeing thread should sleep indefinitely when there's no work to do
https://bugs.webkit.org/show_bug.cgi?id=98084
Reviewed by Geoffrey Garen.
r130212 didn't fully fix the problem.
* heap/BlockAllocator.cpp:
(JSC::BlockAllocator::blockFreeingThreadMain): We would just continue to the next iteration if
we found that we had zero blocks to copy. We should move the indefinite wait up to where that
check is done so that we properly detect the "no more blocks to copy, wait for more" condition.
2012-10-16 Csaba Osztrogonác <ossy@webkit.org>
Unreviewed, rolling out r131516 and r131550.
......
......@@ -102,6 +102,7 @@ void BlockAllocator::blockFreeingThreadStartFunc(void* blockAllocator)
void BlockAllocator::blockFreeingThreadMain()
{
size_t currentNumberOfEmptyRegions;
while (!m_blockFreeingThreadShouldQuit) {
// Generally wait for one second before scavenging free blocks. This
// may return early, particularly when we're being asked to quit.
......@@ -114,12 +115,17 @@ void BlockAllocator::blockFreeingThreadMain()
continue;
}
// Now process the list of free blocks. Keep freeing until half of the
// blocks that are currently on the list are gone. Assume that a size_t
// field can be accessed atomically.
size_t currentNumberOfEmptyRegions = m_numberOfEmptyRegions;
if (!currentNumberOfEmptyRegions)
continue;
// Sleep until there is actually work to do rather than waking up every second to check.
{
MutexLocker locker(m_emptyRegionConditionLock);
SpinLockHolder regionLocker(&m_regionLock);
while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) {
m_regionLock.Unlock();
m_emptyRegionCondition.wait(m_emptyRegionConditionLock);
m_regionLock.Lock();
}
currentNumberOfEmptyRegions = m_numberOfEmptyRegions;
}
size_t desiredNumberOfEmptyRegions = currentNumberOfEmptyRegions / 2;
......@@ -141,16 +147,6 @@ void BlockAllocator::blockFreeingThreadMain()
delete region;
}
// Sleep until there is actually work to do rather than waking up every second to check.
MutexLocker locker(m_emptyRegionConditionLock);
m_regionLock.Lock();
while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) {
m_regionLock.Unlock();
m_emptyRegionCondition.wait(m_emptyRegionConditionLock);
m_regionLock.Lock();
}
m_regionLock.Unlock();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment