summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 23:34:22 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 23:34:22 +0000
commit0500118146171bc4a57ba51cec620b51f139dab8 (patch)
tree015430d44f2e8cd90d4d4bbf0e4f4171d3179fc3 /chrome
parente7f27c9f51fd960b72eda1afbfa36aee2d5a478f (diff)
downloadchromium_src-0500118146171bc4a57ba51cec620b51f139dab8.zip
chromium_src-0500118146171bc4a57ba51cec620b51f139dab8.tar.gz
chromium_src-0500118146171bc4a57ba51cec620b51f139dab8.tar.bz2
Issue 172109: Enable scavenging in RenderThread::IdleHandler.
Landing of Anton Muhin's patch (antonm@google.com) (Reland. First landed in r26264, reverted in r26276. This reland hopefully doesn't build tcmalloc on Linux.) Review URL: http://codereview.chromium.org/206017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/chrome.gyp13
-rw-r--r--chrome/renderer/DEPS1
-rw-r--r--chrome/renderer/render_thread.cc40
3 files changed, 35 insertions, 19 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 2507e3a..4d6f99b 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -2956,6 +2956,12 @@
'include_dirs': [
'third_party/wtl/include',
],
+ 'dependencies': [
+ '../third_party/tcmalloc/tcmalloc.gyp:tcmalloc',
+ ],
+ 'export_dependent_settings': [
+ '../third_party/tcmalloc/tcmalloc.gyp:tcmalloc',
+ ],
},],
],
},
@@ -3621,6 +3627,9 @@
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
],
+ 'export_dependent_settings': [
+ 'renderer',
+ ],
'include_dirs': [
'..',
],
@@ -3701,6 +3710,9 @@
'../skia/skia.gyp:skia',
'../testing/gtest.gyp:gtest',
],
+ 'export_dependent_settings': [
+ 'test_support_common',
+ ],
'include_dirs': [
'..',
],
@@ -4707,7 +4719,6 @@
'../net/net.gyp:net_resources',
'../build/util/support/support.gyp:*',
'../third_party/cld/cld.gyp:cld',
- '../third_party/tcmalloc/tcmalloc.gyp:tcmalloc',
'../views/views.gyp:views',
'../webkit/webkit.gyp:webkit_resources',
'../gears/gears.gyp:gears',
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS
index 4012ed4..f8b66fe 100644
--- a/chrome/renderer/DEPS
+++ b/chrome/renderer/DEPS
@@ -13,6 +13,7 @@ include_rules = [
"+webkit/glue/plugins",
"+v8/include",
"+third_party/sqlite/preprocessed",
+ "+third_party/tcmalloc",
# FIXME - refactor code and remove these dependencies
"+chrome/browser/net",
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index fd076ba..e7c04ed 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -48,6 +48,7 @@
#include "webkit/extensions/v8/gears_extension.h"
#include "webkit/extensions/v8/interval_extension.h"
#include "webkit/extensions/v8/playback_extension.h"
+#include "third_party/tcmalloc/google/malloc_extension.h"
#if defined(OS_WIN)
#include <windows.h>
@@ -459,26 +460,29 @@ void RenderThread::IdleHandler() {
if (!widget_count_ || hidden_widget_count_ < widget_count_)
return;
- if (v8::V8::IsDead())
- return;
-
- LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this;
-
- // When V8::IdleNotification returns true, it means that it has cleaned up
- // as much as it can. There is no point in continuing to call it.
- if (!v8::V8::IdleNotification(false)) {
- // Dampen the delay using the algorithm:
- // delay = delay + 1 / (delay + 2)
- // Using floor(delay) has a dampening effect such as:
- // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
- idle_notification_delay_in_s_ +=
- 1.0 / (idle_notification_delay_in_s_ + 2.0);
+#if defined(OS_WIN)
+ MallocExtension::instance()->Scavenge();
+#endif
- // Schedule the next timer.
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- task_factory_->NewRunnableMethod(&RenderThread::IdleHandler),
- static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000);
+ if (!v8::V8::IsDead()) {
+ LOG(INFO) << "RenderThread calling v8 IdleNotification for " << this;
+ v8::V8::IdleNotification(false);
}
+
+ // Schedule next invocation.
+ // Dampen the delay using the algorithm:
+ // delay = delay + 1 / (delay + 2)
+ // Using floor(delay) has a dampening effect such as:
+ // 1s, 1, 1, 2, 2, 2, 2, 3, 3, ...
+ // Note that idle_notification_delay_in_s_ would be reset to
+ // kInitialIdleHandlerDelayS in RenderThread::WidgetHidden.
+ idle_notification_delay_in_s_ +=
+ 1.0 / (idle_notification_delay_in_s_ + 2.0);
+
+ // Schedule the next timer.
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ task_factory_->NewRunnableMethod(&RenderThread::IdleHandler),
+ static_cast<int64>(floor(idle_notification_delay_in_s_)) * 1000);
}
void RenderThread::OnExtensionMessageInvoke(const std::string& function_name,