Changeset 147150 in webkit
- Timestamp:
- Mar 28, 2013 1:21:08 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r147079 r147150 1 2013-03-28 Mark Hahnenberg <mhahnenberg@apple.com> 2 3 Safari hangs during test262 run in CodeCache::pruneSlowCase 4 https://bugs.webkit.org/show_bug.cgi?id=113469 5 6 Reviewed by Geoffrey Garen. 7 8 We can end up hanging for quite some time if we add a lot of small keys to the CodeCache. 9 By the time we get around to pruning the cache, we have a potentially tens or hundreds of 10 thousands of small entries, which can cause a noticeable hang when pruning them. 11 12 To fix this issue we added a hard cap to the number of entries in the cache because we 13 could potentially have to remove every element in the map. 14 15 * runtime/CodeCache.cpp: 16 (JSC::CodeCacheMap::pruneSlowCase): We need to prune until we're both under the hard cap and the 17 capacity in bytes. 18 * runtime/CodeCache.h: 19 (CodeCacheMap): 20 (JSC::CodeCacheMap::numberOfEntries): Convenience accessor function to the number of entries in 21 the map that does the cast to size_t of m_map.size() for us. 22 (JSC::CodeCacheMap::canPruneQuickly): Checks that the total number is under the hard cap. We put this 23 check inside a function to more accurately describe why we're doing the check and to abstract out 24 the actual calculation in case we want to coalesce calls to pruneSlowCase in the future. 25 (JSC::CodeCacheMap::prune): Check the number of entries against our hard cap. If it's greater than 26 the cap then we need to drop down to pruneSlowCase. 27 1 28 2013-03-28 Zan Dobersek <zdobersek@igalia.com> 2 29 -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r147079 r147150 48 48 m_capacity = m_minCapacity; 49 49 50 while (m_size > m_capacity ) {50 while (m_size > m_capacity || !canPruneQuickly()) { 51 51 MapType::iterator it = m_map.begin(); 52 52 m_size -= it->key.length(); -
trunk/Source/JavaScriptCore/runtime/CodeCache.h
r145171 r147150 197 197 // working set to enter the cache before it starts evicting. 198 198 static const double workingSetTime; 199 static const int64_t workingSetMax = 16000000; 199 static const int64_t workingSetMaxBytes = 16000000; 200 static const size_t workingSetMaxEntries = 2000; 200 201 201 202 // This constant factor biases cache capacity toward recent activity. We … … 208 209 static const int64_t oldObjectSamplingMultiplier = 32; 209 210 211 size_t numberOfEntries() const { return static_cast<size_t>(m_map.size()); } 212 bool canPruneQuickly() const { return numberOfEntries() < workingSetMaxEntries; } 213 210 214 void pruneSlowCase(); 211 215 void prune() 212 216 { 213 if (m_size <= m_capacity )217 if (m_size <= m_capacity && canPruneQuickly()) 214 218 return; 215 219 216 220 if (monotonicallyIncreasingTime() - m_timeAtLastPrune < workingSetTime 217 && m_size - m_sizeAtLastPrune < workingSetMax) 221 && m_size - m_sizeAtLastPrune < workingSetMaxBytes 222 && canPruneQuickly()) 218 223 return; 219 224
Note: See TracChangeset
for help on using the changeset viewer.