New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 759961 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocked on:
issue 778799



Sign in to add a comment

MemoryCache caches async scripts but then GC's them almost immediately afterward

Project Member Reported by vdje...@fb.com, Aug 29 2017

Issue description

The loader memory cache will cache external scripts regardless of whether they have an "async" attribute or not, but it will eagerly prune *only async scripts* as soon as the script has finished executing. This pruning happens during GC.

The memory cache is very important for performance but also quite size constrained (see issue 759958), so inserting an item in the loader's memory cache only to evict it a few seconds later seems counter-productive.
 
Cc: hirosh...@chromium.org
As noted in issue 759958, memory cache is not really a resource cache anymore. Can you post a trace of this issue or URL that consistently repros?

As Hiroshige notes, memory cache just prunes decoded data, but I don't think script resources do any pruning.
ScriptResource is evicted from MemoryCache if it is garbage collected.
Probably, ScriptLoader::Execute() (which is used only for scripts under ScriptRunner, including async scripts) erases the last strong reference to the async ScriptResource, and thus GC can collect the ScriptResource, evicting it from MemoryCache.
Any reason why this is only happening for async scripts for FB?
I haven't tested at all, but I guess probably ScriptLoader::Execute() (used for async scripts) clears |resource_| member, while other paths for executing non-async scripts don't clear that (and |resource_| keeps alive the ScriptResource until the corresponding <script> tag is alive).
Cc: japhet@chromium.org kouhei@chromium.org
Probably, we need to keep the semantics of "Resource is alive and available on MemoryCache, as long as someone is using the Resource", and having a <script> tag explicitly is "using the Resource", so this seems to be counter-intuitive.

If the script source text is anyway referenced by V8 side, then keeping also the ScriptResource alive wouldn't cause the memory consumption regression.

Comment 6 by kouhei@chromium.org, Sep 27 2017

Status: WontFix (was: Untriaged)
I think we want to keep the semantics here as is. The issue to be addressed in different strategy as tracked in  crbug.com/766653 
Blockedon: 778799

Sign in to add a comment