Changeset 93990 in webkit
- Timestamp:
- Aug 29, 2011 11:24:18 AM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r93950 r93990 1 2011-08-29 Andreas Kling <kling@webkit.org> 2 3 Viewing a post on reddit.com wastes a lot of memory on event listeners. 4 https://bugs.webkit.org/show_bug.cgi?id=67133 5 6 Reviewed by Darin Adler. 7 8 Add a minimum table size to the HashTraits, instead of having it hard coded. 9 The default value remains at 64, but can now be specialized. 10 11 * runtime/StructureTransitionTable.h: 12 * wtf/HashTable.h: 13 (WTF::HashTable::shouldShrink): 14 (WTF::::expand): 15 (WTF::::checkTableConsistencyExceptSize): 16 * wtf/HashTraits.h: 17 1 18 2011-08-28 Jonathan Liu <net147@gmail.com> 2 19 -
trunk/Source/JavaScriptCore/runtime/StructureTransitionTable.h
r92810 r93990 65 65 66 66 static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction; 67 68 static const int minimumTableSize = FirstTraits::minimumTableSize; 67 69 68 70 static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); } -
trunk/Source/JavaScriptCore/wtf/HashTable.h
r84718 r93990 378 378 bool shouldExpand() const { return (m_keyCount + m_deletedCount) * m_maxLoad >= m_tableSize; } 379 379 bool mustRehashInPlace() const { return m_keyCount * m_minLoad < m_tableSize * 2; } 380 bool shouldShrink() const { return m_keyCount * m_minLoad < m_tableSize && m_tableSize > m_minTableSize; }380 bool shouldShrink() const { return m_keyCount * m_minLoad < m_tableSize && m_tableSize > KeyTraits::minimumTableSize; } 381 381 void expand(); 382 382 void shrink() { rehash(m_tableSize / 2); } … … 397 397 398 398 #if !ASSERT_DISABLED 399 void checkTableConsisten cyExceptSize() const;399 void checkTableConsistenmcyExceptSize() const; 400 400 #else 401 401 static void checkTableConsistencyExceptSize() { } … … 408 408 #endif 409 409 410 static const int m_minTableSize = 64;411 410 static const int m_maxLoad = 2; 412 411 static const int m_minLoad = 6; … … 902 901 int newSize; 903 902 if (m_tableSize == 0) 904 newSize = m_minTableSize;903 newSize = KeyTraits::minimumTableSize; 905 904 else if (mustRehashInPlace()) 906 905 newSize = m_tableSize; … … 1040 1039 ASSERT(count == m_keyCount); 1041 1040 ASSERT(deletedCount == m_deletedCount); 1042 ASSERT(m_tableSize >= m_minTableSize);1041 ASSERT(m_tableSize >= KeyTraits::minimumTableSize); 1043 1042 ASSERT(m_tableSizeMask); 1044 1043 ASSERT(m_tableSize == m_tableSizeMask + 1); -
trunk/Source/JavaScriptCore/wtf/HashTraits.h
r83664 r93990 39 39 static const bool emptyValueIsZero = false; 40 40 static const bool needsDestruction = true; 41 static const int minimumTableSize = 64; 41 42 }; 42 43 43 44 // Default integer traits disallow both 0 and -1 as keys (max value instead of -1 for unsigned). 44 template<typename T> struct GenericHashTraitsBase<true, T> {45 template<typename T> struct GenericHashTraitsBase<true, T> : GenericHashTraitsBase<false, T> { 45 46 static const bool emptyValueIsZero = true; 46 47 static const bool needsDestruction = false; … … 103 104 static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction; 104 105 106 static const int minimumTableSize = FirstTraits::minimumTableSize; 107 105 108 static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); } 106 109 static bool isDeletedValue(const TraitType& value) { return FirstTraits::isDeletedValue(value.first); } -
trunk/Source/WebCore/ChangeLog
r93988 r93990 1 2011-08-29 Andreas Kling <kling@webkit.org> 2 3 Viewing a post on reddit.com wastes a lot of memory on event listeners. 4 https://bugs.webkit.org/show_bug.cgi?id=67133 5 6 Reviewed by Darin Adler. 7 8 Specialize the HashMap used to store registered listeners on an EventTarget 9 to have a minimum size of 32 (rather than the default 64.) 10 It's very rare for pages to register listeners for so many different events 11 and this cuts memory consumption in half for the common case. 12 13 As an example, for a typical post on the reddit.com front page, 14 this reduces memory used by ~700kB on 64-bit. 15 16 * dom/EventTarget.h: 17 1 18 2011-08-29 Stephen White <senorblanco@chromium.org> 2 19 -
trunk/Source/WebCore/dom/EventTarget.h
r92304 r93990 87 87 88 88 typedef Vector<RegisteredEventListener, 1> EventListenerVector; 89 typedef HashMap<AtomicString, EventListenerVector*> EventListenerMap; 89 90 struct EventListenerMapHashTraits : HashTraits<WTF::AtomicString> { 91 static const int minimumTableSize = 32; 92 }; 93 94 typedef HashMap<AtomicString, EventListenerVector*, AtomicStringHash, EventListenerMapHashTraits> EventListenerMap; 90 95 91 96 struct EventTargetData {
Note: See TracChangeset
for help on using the changeset viewer.