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

Unified Diff: base/allocator/partition_allocator/partition_alloc.cc

Issue 2771033006: PartitionDumpStats(): reduce stack consumption for 'light' reporting. (Closed)
Patch Set: undo ps#2 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/allocator/partition_allocator/partition_alloc.cc
diff --git a/base/allocator/partition_allocator/partition_alloc.cc b/base/allocator/partition_allocator/partition_alloc.cc
index 37d2633b95d59d298c1bf2f538dbe7a7c888c009..439ce177d88a5061ce42e50b50b94f8f0a923a1e 100644
--- a/base/allocator/partition_allocator/partition_alloc.cc
+++ b/base/allocator/partition_allocator/partition_alloc.cc
@@ -1396,27 +1396,42 @@ void PartitionDumpStats(PartitionRoot* partition,
const char* partition_name,
bool is_light_dump,
PartitionStatsDumper* dumper) {
- static const size_t kMaxReportableBuckets = 4096 / sizeof(void*);
- PartitionBucketMemoryStats memory_stats[kMaxReportableBuckets];
- const size_t partitionNumBuckets = partition->num_buckets;
- DCHECK(partitionNumBuckets <= kMaxReportableBuckets);
-
- for (size_t i = 0; i < partitionNumBuckets; ++i)
- PartitionDumpBucketStats(&memory_stats[i], &partition->buckets()[i]);
- // PartitionsDumpBucketStats is called after collecting stats because it
- // can use PartitionAlloc to allocate and this can affect the statistics.
PartitionMemoryStats stats = {0};
stats.total_mmapped_bytes = partition->total_size_of_super_pages;
stats.total_committed_bytes = partition->total_size_of_committed_pages;
DCHECK(!partition->total_size_of_direct_mapped_pages);
+
+ static const size_t kMaxReportableBuckets = 4096 / sizeof(void*);
+ std::unique_ptr<PartitionBucketMemoryStats[]> memory_stats;
+ if (!is_light_dump)
+ memory_stats = std::unique_ptr<PartitionBucketMemoryStats[]>(
+ new PartitionBucketMemoryStats[kMaxReportableBuckets]);
+
+ const size_t partitionNumBuckets = partition->num_buckets;
+ DCHECK(partitionNumBuckets <= kMaxReportableBuckets);
+
for (size_t i = 0; i < partitionNumBuckets; ++i) {
- if (memory_stats[i].is_valid) {
- stats.total_resident_bytes += memory_stats[i].resident_bytes;
- stats.total_active_bytes += memory_stats[i].active_bytes;
- stats.total_decommittable_bytes += memory_stats[i].decommittable_bytes;
- stats.total_discardable_bytes += memory_stats[i].discardable_bytes;
- if (!is_light_dump)
+ PartitionBucketMemoryStats bucket_stats = {0};
+ PartitionDumpBucketStats(&bucket_stats, &partition->buckets()[i]);
+ if (bucket_stats.is_valid) {
+ stats.total_resident_bytes += bucket_stats.resident_bytes;
+ stats.total_active_bytes += bucket_stats.active_bytes;
+ stats.total_decommittable_bytes += bucket_stats.decommittable_bytes;
+ stats.total_discardable_bytes += bucket_stats.discardable_bytes;
+ }
+ if (!is_light_dump) {
+ if (bucket_stats.is_valid)
+ memory_stats[i] = bucket_stats;
+ else
+ memory_stats[i].is_valid = false;
+ }
+ }
+ if (!is_light_dump) {
+ // PartitionsDumpBucketStats is called after collecting stats because it
+ // can use PartitionAlloc to allocate and this can affect the statistics.
+ for (size_t i = 0; i < partitionNumBuckets; ++i) {
+ if (memory_stats[i].is_valid)
dumper->PartitionsDumpBucketStats(partition_name, &memory_stats[i]);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698