Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Issue 100103003: Revert 239763 "Add DiscardableMemoryAllocator to minimize use of..." (Closed)

Created:
7 years ago by Philippe
Modified:
7 years ago
Reviewers:
Philippe
CC:
chromium-reviews
Visibility:
Public.

Description

Revert 239763 "Add DiscardableMemoryAllocator to minimize use of..." > Add DiscardableMemoryAllocator to minimize use of FDs with discardable memory. > > Discardable memory has the current limitation on Android (at least) that it's > backed by a file (descriptor) thus it is a limited resource. > > DiscardableMemoryAllocator provides a way to create instances of > DiscardableMemory in an efficient way. Note that just like regular > DiscardableMemory, the DiscardableMemoryAllocator should not be used for small > allocations since it works with page granularity (4 KBytes). > > On Android DiscardableMemory creation can now happen in two different ways: > - Each client-requested allocation is backed by an individual ashmem region. > This allows to delete ashmem regions individually by closing the ashmem file > descriptor. This is the default path that is taken when file descriptor usage > allows us to do so. > - Allocations are performed by the global allocator when file descriptor usage > gets too high. This still allows unpinning but does not allow deleting > individual regions (i.e. immediately releasing the physycal pages backing > them). Unfortunately the physical memory backing an ashmem region is only > freed when the file descriptor is closed. > madvise(MADV_REMOVE)/fallocate(FALLOCATE_FL_PUNCH_HOLE) don't work with > ashmem unfortunately. > > When file descriptor usage gets too high (which can be observed on > images.google.com for instance) the allocator starts operating by creating as > less ashmem regions (= consuming as less FDs) as possible: > - Large (32 MBytes) ashmem regions get lazily created. This size might need > some tuning/runtime adjustment as a follow up. > - Allocation works first by trying to recycle previously freed chunks (if any) > by doing a closest size match (implemented with multiset<>.lower_bound() in > O(log n)). > If no free chunks can be recycled then a new chunk in the ashmem region is > returned to the user. If the ashmem region is not big enough then a new > region is created. > - DiscardableMemory instance deletion works by marking the chunk used by the > instance as discardable (i.e. ashmem_region_unpin()) and notifying the > allocator with the metadata (e.g. chunk size) that allows it to later recycle > the chunk efficiently. > Note that free chunks are marked as discardable as mentioned above therefore > they can be reclaimed by the kernel under memory pressure. Since they are not > immediately released unfortunately the allocator still tries to minimize > fragmentation (to avoid causing memory pressure) by merging free contiguous > chunks when possible as well as splitting recycled free chunks that are too > large (and that would cause fragmentation). > > BUG=299828 > > Review URL: https://codereview.chromium.org/25293002 TBR=pliard@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=239779

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+60 lines, -924 lines) Patch
M trunk/src/base/base.gyp View 1 chunk +0 lines, -1 line 0 comments Download
M trunk/src/base/base.gypi View 1 chunk +0 lines, -2 lines 0 comments Download
M trunk/src/base/memory/discardable_memory.h View 1 chunk +0 lines, -2 lines 0 comments Download
D trunk/src/base/memory/discardable_memory_allocator_android.h View 1 chunk +0 lines, -65 lines 0 comments Download
D trunk/src/base/memory/discardable_memory_allocator_android.cc View 1 chunk +0 lines, -418 lines 0 comments Download
D trunk/src/base/memory/discardable_memory_allocator_android_unittest.cc View 1 chunk +0 lines, -232 lines 0 comments Download
D trunk/src/base/memory/discardable_memory_android.h View 1 chunk +0 lines, -37 lines 0 comments Download
M trunk/src/base/memory/discardable_memory_android.cc View 3 chunks +60 lines, -152 lines 0 comments Download
M trunk/src/base/memory/discardable_memory_unittest.cc View 1 chunk +0 lines, -15 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
Philippe
7 years ago (2013-12-10 13:59:37 UTC) #1
Philippe
7 years ago (2013-12-10 13:59:47 UTC) #2
Message was sent while issue was closed.
Committed patchset #1 manually as r239779.

Powered by Google App Engine
This is Rietveld 408576698