Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 | 387 |
| 388 // Stores the maximum number of renderer processes the content module can | 388 // Stores the maximum number of renderer processes the content module can |
| 389 // create. | 389 // create. |
| 390 static size_t g_max_renderer_count_override = 0; | 390 static size_t g_max_renderer_count_override = 0; |
| 391 | 391 |
| 392 // static | 392 // static |
| 393 size_t RenderProcessHost::GetMaxRendererProcessCount() { | 393 size_t RenderProcessHost::GetMaxRendererProcessCount() { |
| 394 if (g_max_renderer_count_override) | 394 if (g_max_renderer_count_override) |
| 395 return g_max_renderer_count_override; | 395 return g_max_renderer_count_override; |
| 396 | 396 |
| 397 // Defines the maximum number of renderer processes according to the | 397 // On Android we don't maintain a limit on the number of renderer process |
| 398 // amount of installed memory as reported by the OS. The calculation | 398 // hosts we keep around - we are happy with keeping a lot of these, as long as |
| 399 // assumes that you want the renderers to use half of the installed | 399 // the number of live renderer processes remains reasonable, and on Android |
| 400 // RAM and assuming that each WebContents uses ~40MB. | 400 // the OS takes care of that. |
| 401 // If you modify this assumption, you need to adjust the | 401 #if defined(OS_ANDROID) |
|
klobag.chromium
2014/06/27 16:25:42
hmm, I don't think this is a good way. It makes th
ppi
2014/06/27 16:40:32
But it doesn't diverge too much from the codepaths
ppi
2014/06/27 16:44:32
Should we add a separate boolean function to the A
jam
2014/07/14 22:45:56
I agree with Grace that it's confusing to return 0
ppi
2014/07/16 13:26:54
Done.
| |
| 402 // ThirtyFourTabs test to match the expected number of processes. | 402 return 0u; |
| 403 #endif | |
| 404 | |
| 405 // On other platforms, we calculate the maximum number of renderer process | |
| 406 // hosts according to the amount of installed memory as reported by the OS. | |
| 407 // The calculation assumes that you want the renderers to use half of the | |
| 408 // installed RAM and assuming that each WebContents uses ~40MB. If you modify | |
| 409 // this assumption, you need to adjust the ThirtyFourTabs test to match the | |
| 410 // expected number of processes. | |
| 403 // | 411 // |
| 404 // With the given amounts of installed memory below on a 32-bit CPU, | 412 // With the given amounts of installed memory below on a 32-bit CPU, the |
| 405 // the maximum renderer count will roughly be as follows: | 413 // maximum renderer count will roughly be as follows: |
| 406 // | 414 // |
| 407 // 128 MB -> 3 | 415 // 128 MB -> 3 |
| 408 // 512 MB -> 6 | 416 // 512 MB -> 6 |
| 409 // 1024 MB -> 12 | 417 // 1024 MB -> 12 |
| 410 // 4096 MB -> 51 | 418 // 4096 MB -> 51 |
| 411 // 16384 MB -> 82 (kMaxRendererProcessCount) | 419 // 16384 MB -> 82 (kMaxRendererProcessCount) |
| 412 | 420 |
| 413 static size_t max_count = 0; | 421 static size_t max_count = 0; |
| 414 if (!max_count) { | 422 if (!max_count) { |
| 415 const size_t kEstimatedWebContentsMemoryUsage = | 423 const size_t kEstimatedWebContentsMemoryUsage = |
| (...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1779 return false; | 1787 return false; |
| 1780 | 1788 |
| 1781 if (run_renderer_in_process()) | 1789 if (run_renderer_in_process()) |
| 1782 return true; | 1790 return true; |
| 1783 | 1791 |
| 1784 // NOTE: Sometimes it's necessary to create more render processes than | 1792 // NOTE: Sometimes it's necessary to create more render processes than |
| 1785 // GetMaxRendererProcessCount(), for instance when we want to create | 1793 // GetMaxRendererProcessCount(), for instance when we want to create |
| 1786 // a renderer process for a browser context that has no existing | 1794 // a renderer process for a browser context that has no existing |
| 1787 // renderers. This is OK in moderation, since the | 1795 // renderers. This is OK in moderation, since the |
| 1788 // GetMaxRendererProcessCount() is conservative. | 1796 // GetMaxRendererProcessCount() is conservative. |
| 1789 if (g_all_hosts.Get().size() >= GetMaxRendererProcessCount()) | 1797 size_t render_host_limit = GetMaxRendererProcessCount(); |
| 1798 if (render_host_limit && g_all_hosts.Get().size() >= render_host_limit) | |
|
klobag.chromium
2014/06/27 16:25:42
Should we check the live process count?
ppi
2014/06/27 16:40:32
Dead process hosts can come back (re-spawn their p
| |
| 1790 return true; | 1799 return true; |
| 1791 | 1800 |
| 1792 return GetContentClient()->browser()-> | 1801 return GetContentClient()->browser()-> |
| 1793 ShouldTryToUseExistingProcessHost(browser_context, url); | 1802 ShouldTryToUseExistingProcessHost(browser_context, url); |
| 1794 } | 1803 } |
| 1795 | 1804 |
| 1796 // static | 1805 // static |
| 1797 RenderProcessHost* RenderProcessHost::GetExistingProcessHost( | 1806 RenderProcessHost* RenderProcessHost::GetExistingProcessHost( |
| 1798 BrowserContext* browser_context, | 1807 BrowserContext* browser_context, |
| 1799 const GURL& site_url) { | 1808 const GURL& site_url) { |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2361 void RenderProcessHostImpl::GpuMemoryBufferAllocated( | 2370 void RenderProcessHostImpl::GpuMemoryBufferAllocated( |
| 2362 IPC::Message* reply, | 2371 IPC::Message* reply, |
| 2363 const gfx::GpuMemoryBufferHandle& handle) { | 2372 const gfx::GpuMemoryBufferHandle& handle) { |
| 2364 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2373 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 2365 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 2374 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
| 2366 handle); | 2375 handle); |
| 2367 Send(reply); | 2376 Send(reply); |
| 2368 } | 2377 } |
| 2369 | 2378 |
| 2370 } // namespace content | 2379 } // namespace content |
| OLD | NEW |