MemoryCache caches async scripts but then GC's them almost immediately afterward |
||||
Issue descriptionThe 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.
,
Aug 29 2017
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.
,
Aug 29 2017
Any reason why this is only happening for async scripts for FB?
,
Aug 29 2017
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).
,
Aug 29 2017
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.
,
Sep 27 2017
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
,
Oct 26 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 by csharrison@chromium.org
, Aug 29 2017