diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-09-08 15:24:00 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-09-25 08:39:40 +0000 |
commit | d5d9c3097a151c774e9da476dc9131b69a7cb03d (patch) | |
tree | ea059027d3256849839da6b17a5b4f72b1b6b352 /src/qml/memory | |
parent | 58f9a94f466a0c46e2bf87c22648990497e928e4 (diff) |
Improve algorithm to handle GC of Strings
The old algorithm could lead to excessive garbage collection
in cases where lots of strings are being created.
The new algorithm is a bit more agressive in doubling the GC limit
for string data. This doubles the performance of both the v8 regexp
and splay benchmarks.
Change-Id: I2b5cd27c14410b033038a409d5ae03c9636d4f71
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/memory')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 85f03b17c8..0887e43441 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -64,6 +64,8 @@ #include <pthread_np.h> #endif +#define MIN_UNMANAGED_HEAPSIZE_GC_LIMIT (std::size_t)128*1024 + using namespace WTF; QT_BEGIN_NAMESPACE @@ -124,7 +126,7 @@ struct MemoryManager::Data , maxShift(6) , maxChunkSize(32*1024) , unmanagedHeapSize(0) - , unmanagedHeapSizeGCLimit(64 * 1024) + , unmanagedHeapSizeGCLimit(MIN_UNMANAGED_HEAPSIZE_GC_LIMIT) , largeItems(0) , totalLargeItemsAllocated(0) { @@ -247,13 +249,12 @@ Heap::Base *MemoryManager::allocData(std::size_t size, std::size_t unmanagedSize if (m_d->unmanagedHeapSize > m_d->unmanagedHeapSizeGCLimit) { runGC(); - if (m_d->unmanagedHeapSizeGCLimit <= m_d->unmanagedHeapSize) + if (3*m_d->unmanagedHeapSizeGCLimit <= 4*m_d->unmanagedHeapSize) + // more than 75% full, raise limit m_d->unmanagedHeapSizeGCLimit = std::max(m_d->unmanagedHeapSizeGCLimit, m_d->unmanagedHeapSize) * 2; else if (m_d->unmanagedHeapSize * 4 <= m_d->unmanagedHeapSizeGCLimit) - m_d->unmanagedHeapSizeGCLimit /= 2; - else if (m_d->unmanagedHeapSizeGCLimit - m_d->unmanagedHeapSize < 5 * unmanagedSize) - // try preventing running the GC all the time when we're just below the threshold limit and manage to collect just enough to do this one allocation - m_d->unmanagedHeapSizeGCLimit += std::max(std::size_t(8 * 1024), 5 * unmanagedSize); + // less than 25% full, lower limit + m_d->unmanagedHeapSizeGCLimit = qMax(MIN_UNMANAGED_HEAPSIZE_GC_LIMIT, m_d->unmanagedHeapSizeGCLimit/2); didGCRun = true; } |