Add browser-wide discardable memory implementation.
commit2ac2d83d86b0206b908eea0d6e1002850d238a88
authorreveman <reveman@chromium.org>
Fri, 24 Oct 2014 18:32:51 +0000 (24 11:32 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 24 Oct 2014 18:33:06 +0000 (24 18:33 +0000)
tree1665af1ed0d58288e62bab39aa7ca2dbba4728ac
parentbd5dc60f9e2ce39a6570a487ef06d3f121a900e5
Add browser-wide discardable memory implementation.

This provides a platform agnostic implementation of discardable
memory based on shared memory. Managment of discardable memory is
moved to the browser process instead of being local to each renderer.
This provides much better control over chromium's total discardable
memory usage.

A round-trip to the browser IO thread is necessary for a renderer
to allocate a new discardable memory segment but the cost of this
can be reduced by maintaining free lists on the renderer side and
have discardable memory instances share the same discardable
memory segment. The implementation of this optimization is left as
a follow up.

Note: while the general implementation is platform agnostic, it
takes advantage of the ftruncate syscall available on Posix
platforms. This syscall makes it possible to release discardable
memory segments immediately to the OS from the browser process.

BUG=381178,400423,422953
TEST=base_unittests --gtest_filter=DiscardableMemoryTests*, base_unittests --gtest_filter=DiscardableSharedMemory.*, content_unittests --gtest_filter=HostDiscardableSharedMemoryManagerTest.*

Review URL: https://codereview.chromium.org/531343002

Cr-Commit-Position: refs/heads/master@{#301152}
40 files changed:
base/BUILD.gn
base/base.gyp
base/base.gypi
base/memory/discardable_memory.cc
base/memory/discardable_memory.h
base/memory/discardable_memory_android.cc
base/memory/discardable_memory_ashmem.cc
base/memory/discardable_memory_ashmem.h
base/memory/discardable_memory_emulated.cc
base/memory/discardable_memory_emulated.h
base/memory/discardable_memory_linux.cc
base/memory/discardable_memory_mac.cc
base/memory/discardable_memory_mach.cc
base/memory/discardable_memory_mach.h
base/memory/discardable_memory_manager.cc
base/memory/discardable_memory_manager.h
base/memory/discardable_memory_manager_unittest.cc
base/memory/discardable_memory_shmem.cc [new file with mode: 0644]
base/memory/discardable_memory_shmem.h [copied from base/memory/discardable_memory_ashmem.h with 54% similarity]
base/memory/discardable_memory_shmem_allocator.cc [new file with mode: 0644]
base/memory/discardable_memory_shmem_allocator.h [new file with mode: 0644]
base/memory/discardable_memory_win.cc
base/memory/discardable_shared_memory.cc [new file with mode: 0644]
base/memory/discardable_shared_memory.h [new file with mode: 0644]
base/memory/discardable_shared_memory_unittest.cc [new file with mode: 0644]
chrome/common/crash_keys.cc
content/browser/renderer_host/render_message_filter.cc
content/browser/renderer_host/render_message_filter.h
content/child/child_discardable_shared_memory_manager.cc [new file with mode: 0644]
content/child/child_discardable_shared_memory_manager.h [new file with mode: 0644]
content/child/child_thread.cc
content/child/child_thread.h
content/common/child_process_messages.h
content/common/host_discardable_shared_memory_manager.cc [new file with mode: 0644]
content/common/host_discardable_shared_memory_manager.h [new file with mode: 0644]
content/common/host_discardable_shared_memory_manager_unittest.cc [new file with mode: 0644]
content/content_child.gypi
content/content_common.gypi
content/content_tests.gypi
content/renderer/render_thread_impl.cc