Viewing a post on reddit.com wastes a lot of memory on event listeners.
authorandreas.kling@nokia.com <andreas.kling@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Aug 2011 18:24:18 +0000 (18:24 +0000)
committerandreas.kling@nokia.com <andreas.kling@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Aug 2011 18:24:18 +0000 (18:24 +0000)
commitf9853edaac8d261480a51a3eeb1f26a8a4021671
tree2ae7dfc8be127fcce22ecc8d43f847b61f52765c
parent6a08b8af397d6bf0edc1705123df8ab91e5f8829
Viewing a post on reddit.com wastes a lot of memory on event listeners.
https://bugs.webkit.org/show_bug.cgi?id=67133

Reviewed by Darin Adler.

Source/JavaScriptCore:

Add a minimum table size to the HashTraits, instead of having it hard coded.
The default value remains at 64, but can now be specialized.

* runtime/StructureTransitionTable.h:
* wtf/HashTable.h:
(WTF::HashTable::shouldShrink):
(WTF::::expand):
(WTF::::checkTableConsistencyExceptSize):
* wtf/HashTraits.h:

Source/WebCore:

Specialize the HashMap used to store registered listeners on an EventTarget
to have a minimum size of 32 (rather than the default 64.)
It's very rare for pages to register listeners for so many different events
and this cuts memory consumption in half for the common case.

As an example, for a typical post on the reddit.com front page,
this reduces memory used by ~700kB on 64-bit.

* dom/EventTarget.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93990 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/StructureTransitionTable.h
Source/JavaScriptCore/wtf/HashTable.h
Source/JavaScriptCore/wtf/HashTraits.h
Source/WebCore/ChangeLog
Source/WebCore/dom/EventTarget.h