I will have a look at this.  The heuristic is very bad for this
situation and we will look into what we can do.

Independently of this heuristic, creating contexts is not exactly
cheap, but I guess you do need to have complete separation of those
scripts?

Cheers,    -- Mads

On Wed, Sep 23, 2009 at 1:23 PM, Vitaly Repeshko <[email protected]> wrote:
>
> Can we enhance the heuristic to require that a certain number of
> allocations in the old context must have been made to force a GC?
>
>
> -- Vitaly
>
> On Wed, Sep 23, 2009 at 11:38 AM, Darin Fisher <[email protected]> wrote:
>> What can we do about the negative performance impact this is having on
>> chrome extensions?
>> -Darin
>>
>> On Tue, Sep 22, 2009 at 12:57 PM, Erik Corry <[email protected]> wrote:
>>>
>>>
>>> 2009/9/22 Matt Perry <[email protected]>
>>>>
>>>> First, my question: what is the reason for the call
>>>> to i::Heap::CollectAllGarbageIfContextDisposed() in v8::Context::New? Is it
>>>> just a heuristic that can be removed? Or can we maybe add an API to disable
>>>> this in some cases?
>>>
>>> It's a heuristic.  The idea is that when you navigate to a new page you
>>> will destroy a series of contexts (one per iframe) and then create a new
>>> context for the new main page.  This is a good time to GC because it helps
>>> clear up the DOM nodes from the old page.
>>>
>>>>
>>>> The Chrome extension system introduces a feature called content scripts,
>>>> which allows you to run scripts in a new Context with a handle to the DOM
>>>> window of a target frame. The way this is implemented seems to trigger a
>>>> pathological case in v8::Context::New, causing more GCs than necessary.
>>>> What happens is that content scripts create short-lived Contexts, where
>>>> we create the Context, run some script, and immediately Dispose of it. The
>>>> call to Dispose sets a flag in v8 which causes the next call to
>>>> v8::Context::New to trigger a GC. This means that any time 2+ content
>>>> scripts are run in a given process, we do a GC, slowing down page load.
>>>> You can see the effect of running 50 content scripts on Chrome's startup
>>>> here: http://build.chromium.org/buildbot/perf/xp-release/startup/report.html?history=20 (the
>>>> top green line). If I comment out the call
>>>> to i::Heap::CollectAllGarbageIfContextDisposed(), the startup time for that
>>>> test is cut in half.
>>>>
>>>
>>>
>>>
>>> --
>>> Erik Corry, Software Engineer
>>> Google Denmark ApS.  CVR nr. 28 86 69 84
>>> c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018 Copenhagen
>>> K, Denmark.
>>>
>>>
>>
>>
>> >
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to