Closed Bug 1227689 Opened 9 years ago Closed 9 years ago

Scalability: opening or closing a single tab takes Ω(n) time

Categories

(Firefox :: Untriaged, defect)

42 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 816784

People

(Reporter: baldauf--2015--bugzilla.mozilla.org, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 Build ID: 2015110400 Steps to reproduce: Each time a tab is closed (or an empty tab's document is replaced by a different document due to the user navigating), a WindowDestroyedEvent is created. When handling the WindowDestroyedEvent, method js::NukeCrossCompartmentWrappers() is called (see http://hg.mozilla.org/releases/mozilla-release/annotate/6fd87bafc499/dom/base/nsGlobalWindow.cpp#l9214 ) This method iterates over all compartments (that effectively means: all tabs), and for each interesting compartments, it iterates over all wrappers in that compartment (see http://hg.mozilla.org/releases/mozilla-release/annotate/6fd87bafc499/js/src/proxy/CrossCompartmentWrapper.cpp#l451 ) So effectively, opening or closing one tab takes Ω(n) time. An action where all tabs are opened (e.g. during session restore) thus takes Ω(n²) time. Thus, the current firefox does not scale, while it should. Actual results: See these stack traces: When a tab is closed, then this happens: nsGlobalWindow::NotifyWindowIDDestroyed dom/base/nsGlobalWindow.cpp:9234 nsGlobalWindow::FreeInnerObjects dom/base/nsGlobalWindow.cpp:1632 nsGlobalWindow::DetachFromDocShell dom/base/nsGlobalWindow.cpp:2897 nsDocShell::Destroy docshell/base/nsDocShell.cpp:5715 nsFrameLoader::DestroyDocShell dom/base/nsFrameLoader.cpp:1473 nsFrameLoaderDestroyRunnable::Run dom/base/nsFrameLoader.cpp:1411 When a tab is opened, then this happens: nsGlobalWindow::NotifyWindowIDDestroyed dom/base/nsGlobalWindow.cpp:9234 nsGlobalWindow::FreeInnerObjects dom/base/nsGlobalWindow.cpp:1632 nsGlobalWindow::SetNewDocument dom/base/nsGlobalWindow.cpp:2558 nsDocumentViewer::InitInternal layout/base/nsDocumentViewer.cpp:881 nsDocumentViewer::Init layout/base/nsDocumentViewer.cpp:621 nsDocShell::SetupNewViewer docshell/base/nsDocShell.cpp:9167 nsDocShell::Embed docshell/base/nsDocShell.cpp:7068 nsDocShell::CreateContentViewer docshell/base/nsDocShell.cpp:8975 nsDSURIContentListener::DoContent docshell/base/nsDSURIContentListener.cpp:129 nsDocumentOpenInfo::TryContentListener uriloader/base/nsURILoader.cpp:725 nsDocumentOpenInfo::DispatchContent uriloader/base/nsURILoader.cpp:398 nsDocumentOpenInfo::OnStartRequest uriloader/base/nsURILoader.cpp:259 nsBaseChannel::OnStartRequest netwerk/base/nsBaseChannel.cpp:784 In both cases, a WindowDestroyedEvent is created (see http://hg.mozilla.org/releases/mozilla-release/annotate/6fd87bafc499/dom/base/nsGlobalWindow.cpp#l9234) Expected results: Opening or closing one tab should take O(1) time, not O(n) time. Maybe this can be achieved by keeping the wrappers even if their destination object does not exist anymore. At least, restoring a session should take O(n) time, not O(n²) time.
This is very similar to Bug 816784.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.