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

Side by Side Diff: Source/platform/heap/Heap.cpp

Issue 1217793002: [tracing] Avoid double-counting blink_gc free stats in memory-infra (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // Add the BaseHeap's pages to the orphanedPagePool. 255 // Add the BaseHeap's pages to the orphanedPagePool.
256 for (BasePage* page = m_firstPage; page; page = page->next()) { 256 for (BasePage* page = m_firstPage; page; page = page->next()) {
257 Heap::decreaseAllocatedSpace(page->size()); 257 Heap::decreaseAllocatedSpace(page->size());
258 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); 258 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page);
259 } 259 }
260 m_firstPage = nullptr; 260 m_firstPage = nullptr;
261 } 261 }
262 262
263 void BaseHeap::takeSnapshot(const String& dumpBaseName) 263 void BaseHeap::takeSnapshot(const String& dumpBaseName)
264 { 264 {
265 // |dumpBaseName| at this point is "blink_gc/thread_X/heaps/HeapName"
265 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); 266 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
266 size_t pageIndex = 0; 267 size_t pageIndex = 0;
268 size_t heapTotalFreeSize = 0;
269 size_t heapTotalFreeCount = 0;
267 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 270 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
268 page->takeSnapshot(dumpBaseName, pageIndex); 271 size_t heapPageFreeSize = 0;
272 size_t heapPageFreeCount = 0;
273 page->takeSnapshot(dumpBaseName, pageIndex, &heapPageFreeSize, &heapPage FreeCount);
274 heapTotalFreeSize += heapPageFreeSize;
275 heapTotalFreeCount += heapPageFreeCount;
269 pageIndex++; 276 pageIndex++;
270 } 277 }
271 allocatorDump->AddScalar("blink_page_count", "objects", pageIndex); 278 allocatorDump->AddScalar("blink_page_count", "objects", pageIndex);
279
280 // When taking a full dump (w/ freelist), both the /buckets and /pages
281 // report their free size but they are not meant to be added together.
282 // Therefore, here we override the free_size of the parent heap to be
283 // eqauel to the free_size of the sum of its heap pages.
haraken 2015/06/29 11:55:29 equal
284 allocatorDump->AddScalar("free_size", "bytes", heapTotalFreeSize);
285 allocatorDump->AddScalar("free_count", "objects", heapTotalFreeCount);
272 } 286 }
273 287
274 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) 288 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING)
275 BasePage* BaseHeap::findPageFromAddress(Address address) 289 BasePage* BaseHeap::findPageFromAddress(Address address)
276 { 290 {
277 for (BasePage* page = m_firstPage; page; page = page->next()) { 291 for (BasePage* page = m_firstPage; page; page = page->next()) {
278 if (page->contains(address)) 292 if (page->contains(address))
279 return page; 293 return page;
280 } 294 }
281 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 295 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 for (size_t i = 0; i < blinkPageSizeLog2; ++i) { 1157 for (size_t i = 0; i < blinkPageSizeLog2; ++i) {
1144 size_t entryCount = 0; 1158 size_t entryCount = 0;
1145 size_t freeSize = 0; 1159 size_t freeSize = 0;
1146 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) { 1160 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) {
1147 ++entryCount; 1161 ++entryCount;
1148 freeSize += entry->size(); 1162 freeSize += entry->size();
1149 } 1163 }
1150 1164
1151 String dumpName = dumpBaseName + String::format("/buckets/bucket_%lu", s tatic_cast<unsigned long>(1 << i)); 1165 String dumpName = dumpBaseName + String::format("/buckets/bucket_%lu", s tatic_cast<unsigned long>(1 << i));
1152 WebMemoryAllocatorDump* bucketDump = BlinkGCMemoryDumpProvider::instance ()->createMemoryAllocatorDumpForCurrentGC(dumpName); 1166 WebMemoryAllocatorDump* bucketDump = BlinkGCMemoryDumpProvider::instance ()->createMemoryAllocatorDumpForCurrentGC(dumpName);
1153 bucketDump->AddScalar("freelist_entry_count", "objects", entryCount); 1167 bucketDump->AddScalar("free_count", "objects", entryCount);
1154 bucketDump->AddScalar("free_size", "bytes", freeSize); 1168 bucketDump->AddScalar("free_size", "bytes", freeSize);
1155 didDumpBucketStats = true; 1169 didDumpBucketStats = true;
1156 } 1170 }
1157 return didDumpBucketStats; 1171 return didDumpBucketStats;
1158 } 1172 }
1159 1173
1160 #if ENABLE(GC_PROFILING) 1174 #if ENABLE(GC_PROFILING)
1161 void FreeList::getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& to talFreeSize) const 1175 void FreeList::getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& to talFreeSize) const
1162 { 1176 {
1163 totalFreeSize = 0; 1177 totalFreeSize = 0;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 // cross thread pointer usage. 1494 // cross thread pointer usage.
1481 #if defined(ADDRESS_SANITIZER) 1495 #if defined(ADDRESS_SANITIZER)
1482 // This needs to zap poisoned memory as well. 1496 // This needs to zap poisoned memory as well.
1483 // Force unpoison memory before memset. 1497 // Force unpoison memory before memset.
1484 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); 1498 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize());
1485 #endif 1499 #endif
1486 memset(payload(), orphanedZapValue, payloadSize()); 1500 memset(payload(), orphanedZapValue, payloadSize());
1487 BasePage::markOrphaned(); 1501 BasePage::markOrphaned();
1488 } 1502 }
1489 1503
1490 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex) 1504 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex, size_t* outFree Size, size_t* outFreeCount)
1491 { 1505 {
1492 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex))); 1506 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex)));
1493 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); 1507 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName);
1494 1508
1495 HeapObjectHeader* header = nullptr; 1509 HeapObjectHeader* header = nullptr;
1496 size_t liveCount = 0; 1510 size_t liveCount = 0;
1497 size_t deadCount = 0; 1511 size_t deadCount = 0;
1498 size_t freeCount = 0; 1512 size_t freeCount = 0;
1499 size_t liveSize = 0; 1513 size_t liveSize = 0;
1500 size_t deadSize = 0; 1514 size_t deadSize = 0;
(...skipping 11 matching lines...) Expand all
1512 deadSize += header->size(); 1526 deadSize += header->size();
1513 } 1527 }
1514 } 1528 }
1515 1529
1516 pageDump->AddScalar("live_count", "objects", liveCount); 1530 pageDump->AddScalar("live_count", "objects", liveCount);
1517 pageDump->AddScalar("dead_count", "objects", deadCount); 1531 pageDump->AddScalar("dead_count", "objects", deadCount);
1518 pageDump->AddScalar("free_count", "objects", freeCount); 1532 pageDump->AddScalar("free_count", "objects", freeCount);
1519 pageDump->AddScalar("live_size", "bytes", liveSize); 1533 pageDump->AddScalar("live_size", "bytes", liveSize);
1520 pageDump->AddScalar("dead_size", "bytes", deadSize); 1534 pageDump->AddScalar("dead_size", "bytes", deadSize);
1521 pageDump->AddScalar("free_size", "bytes", freeSize); 1535 pageDump->AddScalar("free_size", "bytes", freeSize);
1536 *outFreeSize = freeSize;
1537 *outFreeCount = freeCount;
1522 } 1538 }
1523 1539
1524 #if ENABLE(GC_PROFILING) 1540 #if ENABLE(GC_PROFILING)
1525 const GCInfo* NormalPage::findGCInfo(Address address) 1541 const GCInfo* NormalPage::findGCInfo(Address address)
1526 { 1542 {
1527 if (address < payload()) 1543 if (address < payload())
1528 return nullptr; 1544 return nullptr;
1529 1545
1530 HeapObjectHeader* header = findHeaderFromAddress(address); 1546 HeapObjectHeader* header = findHeaderFromAddress(address);
1531 if (!header) 1547 if (!header)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 } 1705 }
1690 1706
1691 void LargeObjectPage::markOrphaned() 1707 void LargeObjectPage::markOrphaned()
1692 { 1708 {
1693 // Zap the payload with a recognizable value to detect any incorrect 1709 // Zap the payload with a recognizable value to detect any incorrect
1694 // cross thread pointer usage. 1710 // cross thread pointer usage.
1695 memset(payload(), orphanedZapValue, payloadSize()); 1711 memset(payload(), orphanedZapValue, payloadSize());
1696 BasePage::markOrphaned(); 1712 BasePage::markOrphaned();
1697 } 1713 }
1698 1714
1699 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex) 1715 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex, size_t* ou tFreeSize, size_t* outFreeCount)
1700 { 1716 {
1701 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex))); 1717 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex)));
1702 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); 1718 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName);
1703 1719
1704 size_t liveSize = 0; 1720 size_t liveSize = 0;
1705 size_t deadSize = 0; 1721 size_t deadSize = 0;
1706 size_t liveCount = 0; 1722 size_t liveCount = 0;
1707 size_t deadCount = 0; 1723 size_t deadCount = 0;
1708 HeapObjectHeader* header = heapObjectHeader(); 1724 HeapObjectHeader* header = heapObjectHeader();
1709 if (header->isMarked()) { 1725 if (header->isMarked()) {
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
2443 size_t Heap::s_allocatedObjectSize = 0; 2459 size_t Heap::s_allocatedObjectSize = 0;
2444 size_t Heap::s_allocatedSpace = 0; 2460 size_t Heap::s_allocatedSpace = 0;
2445 size_t Heap::s_markedObjectSize = 0; 2461 size_t Heap::s_markedObjectSize = 0;
2446 // We don't want to use 0 KB for the initial value because it may end up 2462 // We don't want to use 0 KB for the initial value because it may end up
2447 // triggering the first GC of some thread too prematurely. 2463 // triggering the first GC of some thread too prematurely.
2448 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; 2464 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024;
2449 size_t Heap::s_externalObjectSizeAtLastGC = 0; 2465 size_t Heap::s_externalObjectSizeAtLastGC = 0;
2450 double Heap::s_estimatedMarkingTimePerByte = 0.0; 2466 double Heap::s_estimatedMarkingTimePerByte = 0.0;
2451 2467
2452 } // namespace blink 2468 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698