Both the memory efficiency and sharing efficiency of CSSPrimitiveValueCache can be improved by using HashMaps instead of fixed size arrays.
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.
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.
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().
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.
http://trac.webkit.org/changeset/80477 (with single hash lookups)
http://trac.webkit.org/changeset/80477 might have broken Qt Linux Release