summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-21 16:46:32 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-21 16:46:32 +0000
commitc2a797d2872ec1a32339adca5b8fd1441dc27934 (patch)
treefaf1cbb4ecbf5b429f343e276042fbf12370884a
parent538813c1332b409aae3f9a05921fddb6e6734bb5 (diff)
downloadchromium_src-c2a797d2872ec1a32339adca5b8fd1441dc27934.zip
chromium_src-c2a797d2872ec1a32339adca5b8fd1441dc27934.tar.gz
chromium_src-c2a797d2872ec1a32339adca5b8fd1441dc27934.tar.bz2
Add histograms for tab count, RenderProcessHost count, and the number of
glyph "pages" in memory per load (to check memory consumption). BUG=none TEST=none Review URL: http://codereview.chromium.org/195104 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26688 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_list.cc81
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc18
-rw-r--r--chrome/renderer/render_view.cc5
-rw-r--r--webkit/glue/webkit_glue.cc5
-rw-r--r--webkit/glue/webkit_glue.h5
5 files changed, 103 insertions, 11 deletions
diff --git a/chrome/browser/browser_list.cc b/chrome/browser/browser_list.cc
index 56984a0..6a1f2c2 100644
--- a/chrome/browser/browser_list.cc
+++ b/chrome/browser/browser_list.cc
@@ -1,26 +1,82 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "build/build_config.h"
-
#include "chrome/browser/browser_list.h"
+#include "base/histogram.h"
#include "base/logging.h"
#include "base/message_loop.h"
+#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/profile_manager.h"
+#include "chrome/browser/tab_contents/navigation_controller.h"
+#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/result_codes.h"
-#if defined(OS_WIN)
-// TODO(port): these can probably all go away, even on win
-#include "chrome/browser/profile.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#endif
+namespace {
+// This object is instantiated when the first Browser object is added to the
+// list and delete when the last one is removed. It watches for loads and
+// creates histograms of some global object counts.
+class BrowserActivityObserver : public NotificationObserver {
+ public:
+ BrowserActivityObserver() {
+ registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
+ NotificationService::AllSources());
+ }
+ ~BrowserActivityObserver() {}
+
+ private:
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(type == NotificationType::NAV_ENTRY_COMMITTED);
+ const NavigationController::LoadCommittedDetails& load =
+ *Details<NavigationController::LoadCommittedDetails>(details).ptr();
+ if (!load.is_main_frame || load.is_auto || load.is_in_page)
+ return; // Don't log for subframes or other trivial types.
+
+ LogRenderProcessHostCount();
+ LogBrowserTabCount();
+ }
+
+ // Counts the number of active RenderProcessHosts and logs them.
+ void LogRenderProcessHostCount() const {
+ int hosts_count = 0;
+ RenderProcessHost::iterator iter(RenderProcessHost::AllHostsIterator());
+ while (!iter.IsAtEnd()) {
+ hosts_count++;
+ iter.Advance();
+ }
+ UMA_HISTOGRAM_CUSTOM_COUNTS("MPArch.RPHCountPerLoad", hosts_count,
+ 1, 50, 50);
+ }
+
+ // Counts the number of tabs in each browser window and logs them. This is
+ // different than the number of TabContents objects since TabContents objects
+ // can be used for popups and in dialog boxes. We're just counting toplevel
+ // tabs here.
+ void LogBrowserTabCount() const {
+ int tab_count = 0;
+ for (BrowserList::const_iterator browser_iterator = BrowserList::begin();
+ browser_iterator != BrowserList::end(); browser_iterator++)
+ tab_count += (*browser_iterator)->tab_count();
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountPerLoad", tab_count, 1, 200, 50);
+ }
+
+ NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserActivityObserver);
+};
+
+BrowserActivityObserver* activity_observer = NULL;
+
+} // namespace
BrowserList::list_type BrowserList::browsers_;
std::vector<BrowserList::Observer*> BrowserList::observers_;
@@ -32,6 +88,9 @@ void BrowserList::AddBrowser(Browser* browser) {
g_browser_process->AddRefModule();
+ if (!activity_observer)
+ activity_observer = new BrowserActivityObserver;
+
NotificationService::current()->Notify(
NotificationType::BROWSER_OPENED,
Source<Browser>(browser),
@@ -67,9 +126,13 @@ void BrowserList::RemoveBrowser(Browser* browser) {
// If the last Browser object was destroyed, make sure we try to close any
// remaining dependent windows too.
- if (browsers_.empty())
+ if (browsers_.empty()) {
AllBrowsersClosed();
+ delete activity_observer;
+ activity_observer = NULL;
+ }
+
g_browser_process->ReleaseModule();
}
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index b757e46..5e4feaa 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -361,9 +361,10 @@ bool BrowserRenderProcessHost::Init() {
// relating to the FieldTrial states.
std::string field_trial_states;
FieldTrialList::StatesToString(&field_trial_states);
- if (!field_trial_states.empty())
+ if (!field_trial_states.empty()) {
cmd_line.AppendSwitchWithValue(switches::kForceFieldTestNameAndValue,
ASCIIToWide(field_trial_states));
+ }
#if defined(OS_POSIX)
const bool has_cmd_prefix =
@@ -407,6 +408,7 @@ bool BrowserRenderProcessHost::Init() {
#endif
in_process_renderer_->StartWithOptions(options);
} else {
+ base::TimeTicks begin_launch_time = base::TimeTicks::Now();
base::ProcessHandle process = 0;
#if defined(OS_WIN)
process = sandbox::StartProcess(&cmd_line);
@@ -447,13 +449,25 @@ bool BrowserRenderProcessHost::Init() {
#if defined(OS_LINUX)
}
#endif // defined(OS_LINUX)
-#endif // defined(OS_WIN)
+#endif // defined(OS_POSIX)
if (!process) {
channel_.reset();
return false;
}
process_.set_handle(process);
+
+ // Log the launch time, separating out the first one (which will likely be
+ // slower due to the rest of the browser initializing at the same time).
+ static bool done_first_launch = false;
+ if (done_first_launch) {
+ UMA_HISTOGRAM_TIMES("MPArch.RendererLaunchSubsequent",
+ base::TimeTicks::Now() - begin_launch_time);
+ } else {
+ UMA_HISTOGRAM_TIMES("MPArch.RendererLaunchFirst",
+ base::TimeTicks::Now() - begin_launch_time);
+ done_first_launch = true;
+ }
}
resource_message_filter->Init();
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index a1aea97..ddd1793 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1019,6 +1019,11 @@ void RenderView::UpdateURL(WebFrame* frame) {
if (EqualsASCII(method, "POST"))
params.is_post = true;
+ // Save some histogram data so we can compute the average memory used per
+ // page load of the glyphs.
+ UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad",
+ webkit_glue::GetGlyphPageCount());
+
Send(new ViewHostMsg_FrameNavigate(routing_id_, params));
} else {
// Subframe navigation: the type depends on whether this navigation
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 323a454..a8575f0 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -17,6 +17,7 @@
#include "FrameTree.h"
#include "FrameView.h"
#include "Frame.h"
+#include "GlyphPageTreeNode.h"
#include "HistoryItem.h"
#include "ImageSource.h"
#include "KURL.h"
@@ -448,4 +449,8 @@ WebCanvas* ToWebCanvas(skia::PlatformCanvas* canvas) {
#endif
}
+int GetGlyphPageCount() {
+ return WebCore::GlyphPageTreeNode::treeGlyphPageCount();
+}
+
} // namespace webkit_glue
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index eab53a4..cd49bf3 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -117,6 +117,11 @@ WebKit::WebString FilePathToWebString(const FilePath& file_path);
// Returns a WebCanvas pointer associated with the given Skia canvas.
WebKit::WebCanvas* ToWebCanvas(skia::PlatformCanvas*);
+// Returns the number of currently-active glyph pages this process is using.
+// There can be many such pages (maps of 256 character -> glyph) so this is
+// used to get memory usage statistics.
+int GetGlyphPageCount();
+
//---- END FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE -------------------------------