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?

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.

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

Reply via email to