Ignore:
Timestamp:
Feb 18, 2013, 5:39:12 PM (12 years ago)
Author:
[email protected]
Message:

Shrank the SourceProvider cache
https://bugs.webkit.org/show_bug.cgi?id=110158

Reviewed by Oliver Hunt.

Source/JavaScriptCore:

CodeCache is now our primary source cache, so a long-lived SourceProvider
cache is a waste. I measured this as a 10MB Membuster win; with more
precise instrumentation, Andreas estimated it as up to 30MB.

I didn't eliminate the SourceProvider cache because it's still useful
in speeding up uncached parsing of scripts with large nested functions
(i.e., all scripts).

  • heap/Heap.cpp:

(JSC::Heap::collect): Discard all source provider caches after GC. This
is a convenient place to do so because it's reasonably soon after initial
parsing without being immediate.

  • parser/Parser.cpp:

(JSC::::Parser): Updated for interface change: The heap now owns the
source provider cache, since most SourceProviders are not expected to
have one by default, and the heap is responsible for throwing them away.

(JSC::::parseInner): No need to update statistics on cache size, since
we're going to throw it away no matter what.

(JSC::::parseFunctionInfo): Reduced the minimum function size to 16. This
is a 27% win on a new parsing micro-benchmark I've added. Now that the
cache is temporary, we don't have to worry so much about its memory
footprint.

  • parser/Parser.h:

(Parser): Updated for interface changes.

  • parser/SourceProvider.cpp:

(JSC::SourceProvider::SourceProvider):
(JSC::SourceProvider::~SourceProvider):

  • parser/SourceProvider.h:

(JSC):
(SourceProvider): SourceProvider doesn't own its cache anymore because
the cache is temporary.

  • parser/SourceProviderCache.cpp:

(JSC::SourceProviderCache::clear):
(JSC::SourceProviderCache::add):

  • parser/SourceProviderCache.h:

(JSC::SourceProviderCache::SourceProviderCache):
(SourceProviderCache):

  • parser/SourceProviderCacheItem.h:

(SourceProviderCacheItem): No need to update statistics on cache size,
since we're going to throw it away no matter what.

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::addSourceProviderCache):
(JSC):
(JSC::JSGlobalData::clearSourceProviderCaches):

  • runtime/JSGlobalData.h:

(JSC):
(JSGlobalData): Moved the cache here so it's easier to throw away.

Source/WebCore:

Test: fast/js/regress/nested-function-parsing.html

No need to keep statistics on cache size, since we're going to throw it
away no matter what.

  • WebCore.order:
  • bindings/js/CachedScriptSourceProvider.h:

(CachedScriptSourceProvider):
(WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):

  • loader/cache/CachedScript.cpp:

(WebCore::CachedScript::destroyDecodedData):
(WebCore):
(WebCore::CachedScript::reportMemoryUsage):

  • loader/cache/CachedScript.h:

(CachedScript):

LayoutTests:

New benchmark to show that a minimum size of 16 is better than 64.

  • fast/js/regress/nested-function-parsing-expected.txt: Added.
  • fast/js/regress/nested-function-parsing.html: Added.
  • fast/js/regress/script-tests/nested-function-parsing.js: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SourceProviderCache.cpp

    r104318 r143279  
    3737{
    3838    m_map.clear();
    39     m_contentByteSize = 0;
    4039}
    4140
    42 unsigned SourceProviderCache::byteSize() const
    43 {
    44     return m_contentByteSize + sizeof(*this) + m_map.capacity() * sizeof(SourceProviderCacheItem*);
    45 }
    46 
    47 void SourceProviderCache::add(int sourcePosition, PassOwnPtr<SourceProviderCacheItem> item, unsigned size)
     41void SourceProviderCache::add(int sourcePosition, PassOwnPtr<SourceProviderCacheItem> item)
    4842{
    4943    m_map.add(sourcePosition, item);
    50     m_contentByteSize += size;
    5144}
    5245
Note: See TracChangeset for help on using the changeset viewer.