Title: [130212] trunk/Source/_javascript_Core
- Revision
- 130212
- Author
- mhahnenb...@apple.com
- Date
- 2012-10-02 14:24:19 -0700 (Tue, 02 Oct 2012)
Log Message
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.
Currently 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.
* heap/BlockAllocator.cpp:
(JSC::BlockAllocator::BlockAllocator):
(JSC::BlockAllocator::blockFreeingThreadMain):
* heap/BlockAllocator.h:
(BlockAllocator):
(JSC::BlockAllocator::deallocate):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (130211 => 130212)
--- trunk/Source/_javascript_Core/ChangeLog 2012-10-02 21:10:21 UTC (rev 130211)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-10-02 21:24:19 UTC (rev 130212)
@@ -1,3 +1,22 @@
+2012-10-01 Mark Hahnenberg <mhahnenb...@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.
+
+ Currently 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.
+
+ * heap/BlockAllocator.cpp:
+ (JSC::BlockAllocator::BlockAllocator):
+ (JSC::BlockAllocator::blockFreeingThreadMain):
+ * heap/BlockAllocator.h:
+ (BlockAllocator):
+ (JSC::BlockAllocator::deallocate):
+
2012-10-01 Michael Saboff <msab...@apple.com>
JSArray::unshiftCountSlowCase needs to clear array slots when adding space to end of array
Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.cpp (130211 => 130212)
--- trunk/Source/_javascript_Core/heap/BlockAllocator.cpp 2012-10-02 21:10:21 UTC (rev 130211)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.cpp 2012-10-02 21:24:19 UTC (rev 130212)
@@ -138,6 +138,16 @@
DeadBlock::destroy(block).deallocate();
}
+
+ // Sleep until there is actually work to do rather than waking up every second to check.
+ MutexLocker locker(m_freeBlockConditionLock);
+ m_freeBlockLock.Lock();
+ while (!m_numberOfFreeBlocks && !m_blockFreeingThreadShouldQuit) {
+ m_freeBlockLock.Unlock();
+ m_freeBlockCondition.wait(m_freeBlockConditionLock);
+ m_freeBlockLock.Lock();
+ }
+ m_freeBlockLock.Unlock();
}
}
Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.h (130211 => 130212)
--- trunk/Source/_javascript_Core/heap/BlockAllocator.h 2012-10-02 21:10:21 UTC (rev 130211)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.h 2012-10-02 21:24:19 UTC (rev 130212)
@@ -104,9 +104,17 @@
inline void BlockAllocator::deallocate(PageAllocationAligned allocation)
{
- SpinLockHolder locker(&m_freeBlockLock);
- m_freeBlocks.push(DeadBlock::create(allocation));
- m_numberOfFreeBlocks++;
+ size_t numberOfFreeBlocks;
+ {
+ SpinLockHolder locker(&m_freeBlockLock);
+ m_freeBlocks.push(DeadBlock::create(allocation));
+ numberOfFreeBlocks = m_numberOfFreeBlocks++;
+ }
+
+ if (!numberOfFreeBlocks) {
+ MutexLocker mutexLocker(m_freeBlockConditionLock);
+ m_freeBlockCondition.signal();
+ }
}
} // namespace JSC
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes