summaryrefslogtreecommitdiffstats
path: root/runtime/gc/allocator/rosalloc.h
diff options
context:
space:
mode:
authorHiroshi Yamauchi <yamauchi@google.com>2014-02-27 11:27:10 -0800
committerHiroshi Yamauchi <yamauchi@google.com>2014-03-03 17:44:15 -0800
commit26d69ffc0ebc98fbc5f316d8cd3ee6ba5b2001ac (patch)
tree5ac4599dd8198cf4c6e8d265bf509dcef8acd89b /runtime/gc/allocator/rosalloc.h
parenta9242dfd0a9547141ddaba84cd4e2ea0117dff5b (diff)
downloadandroid_art-26d69ffc0ebc98fbc5f316d8cd3ee6ba5b2001ac.tar.gz
android_art-26d69ffc0ebc98fbc5f316d8cd3ee6ba5b2001ac.tar.bz2
android_art-26d69ffc0ebc98fbc5f316d8cd3ee6ba5b2001ac.zip
Decrease lock uses in RosAlloc::BulkFree().
Read rosalloc page map entries without a lock. Disabled for now. This change speeds up Ritz MemAllocTest by ~25% on host and reduces the GC sweep time, but somehow slows it down by ~5% on N4, which is why it's disabled for now. TODO: look into the slowdown on N4 more. Bug: 8262791 Bug: 11790317 Change-Id: I936bbee9cfbd389e70d6343503bf0923865d2a2c
Diffstat (limited to 'runtime/gc/allocator/rosalloc.h')
-rw-r--r--runtime/gc/allocator/rosalloc.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/runtime/gc/allocator/rosalloc.h b/runtime/gc/allocator/rosalloc.h
index dd2bb5ded0..4b0dd792f3 100644
--- a/runtime/gc/allocator/rosalloc.h
+++ b/runtime/gc/allocator/rosalloc.h
@@ -27,6 +27,8 @@
#include "base/mutex.h"
#include "base/logging.h"
#include "globals.h"
+#include "mem_map.h"
+#include "UniquePtr.h"
#include "utils.h"
// A boilerplate to use hash_map/hash_set both on host and device.
@@ -51,6 +53,7 @@ using __gnu_cxx::hash_set;
#endif // HAVE_ANDROID_OS
namespace art {
+
namespace gc {
namespace allocator {
@@ -428,9 +431,13 @@ class RosAlloc {
size_t footprint_;
// The maximum footprint. The address, base_ + capacity_, indicates
- // the end of the memory region that's managed by this allocator.
+ // the end of the memory region that's currently managed by this allocator.
size_t capacity_;
+ // The maximum capacity. The address, base_ + max_capacity_, indicates
+ // the end of the memory region that's ever managed by this allocator.
+ size_t max_capacity_;
+
// The run sets that hold the runs whose slots are not all
// full. non_full_runs_[i] is guarded by size_bracket_locks_[i].
std::set<Run*> non_full_runs_[kNumOfSizeBrackets];
@@ -454,7 +461,11 @@ class RosAlloc {
kPageMapLargeObjectPart = 4, // The non-beginning part of a large object.
};
// The table that indicates what pages are currently used for.
- std::vector<byte> page_map_ GUARDED_BY(lock_);
+ byte* page_map_; // No GUARDED_BY(lock_) for kReadPageMapEntryWithoutLockInBulkFree.
+ size_t page_map_size_;
+ size_t max_page_map_size_;
+ UniquePtr<MemMap> page_map_mem_map_;
+
// The table that indicates the size of free page runs. These sizes
// are stored here to avoid storing in the free page header and
// release backing pages.
@@ -501,7 +512,7 @@ class RosAlloc {
void* AllocLargeObject(Thread* self, size_t size, size_t* bytes_allocated) LOCKS_EXCLUDED(lock_);
public:
- RosAlloc(void* base, size_t capacity,
+ RosAlloc(void* base, size_t capacity, size_t max_capacity,
PageReleaseMode page_release_mode,
size_t page_release_size_threshold = kDefaultPageReleaseSizeThreshold);
void* Alloc(Thread* self, size_t size, size_t* bytes_allocated)