RESOLVED FIXED 55873
Use HashMaps for caching primitive values
https://bugs.webkit.org/show_bug.cgi?id=55873
Summary Use HashMaps for caching primitive values
Antti Koivisto
Reported 2011-03-07 06:00:39 PST
Both the memory efficiency and sharing efficiency of CSSPrimitiveValueCache can be improved by using HashMaps instead of fixed size arrays.
Attachments
use HashMaps instead of fixed size arrays for caching (6.17 KB, patch)
2011-03-07 06:20 PST, Antti Koivisto
sam: review+
Antti Koivisto
Comment 1 2011-03-07 06:20:59 PST
Created attachment 84939 [details] use HashMaps instead of fixed size arrays for caching This removes the fixed per-document cost of empty cache (was ~10kb on 32bit) while also somewhat improving caching efficiency (~5% from expanded integer range which more than pays for itself). Caches usually cover only a fraction of possible values so increased per-item cost from the hash table is ok.
WebKit Review Bot
Comment 2 2011-03-07 06:24:03 PST
Attachment 84939 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1 Source/WebCore/css/CSSPrimitiveValueCache.cpp:97: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Source/WebCore/css/CSSPrimitiveValueCache.cpp:102: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Source/WebCore/css/CSSPrimitiveValueCache.cpp:107: Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons. [readability/comparison_to_zero] [5] Total errors found: 3 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
mitz
Comment 3 2011-03-07 08:22:09 PST
Comment on attachment 84939 [details] use HashMaps instead of fixed size arrays for caching View in context: https://bugs.webkit.org/attachment.cgi?id=84939&action=review > Source/WebCore/css/CSSPrimitiveValueCache.cpp:53 > + m_identifierValueCache.add(ident, primitiveValue); A get() followed by an add() means two cache lookups. You can do this with a single add().
Sam Weinig
Comment 4 2011-03-07 09:00:35 PST
Comment on attachment 84939 [details] use HashMaps instead of fixed size arrays for caching View in context: https://bugs.webkit.org/attachment.cgi?id=84939&action=review > Source/WebCore/css/CSSPrimitiveValueCache.cpp:119 > + RefPtr<CSSPrimitiveValue> primitiveValue = cache->get(intValue); > if (!primitiveValue) { > primitiveValue = CSSPrimitiveValue::create(value, type); > - m_integerValueCache[intValue][type] = primitiveValue; > + cache->add(intValue, primitiveValue); > } Same comment as the the one mitz gave above. This can be done with one hash lookup.
Antti Koivisto
Comment 5 2011-03-07 10:54:10 PST
http://trac.webkit.org/changeset/80477 (with single hash lookups)
WebKit Review Bot
Comment 6 2011-03-07 11:10:49 PST
http://trac.webkit.org/changeset/80477 might have broken Qt Linux Release
Note You need to log in before you can comment on or make changes to this bug.