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

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

Issue 1149703002: Adding heap-page statistics to blink-gc memory dump provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@oilpan_v1
Patch Set: Fixing error. Created 5 years, 6 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Add the BaseHeap's pages to the orphanedPagePool. 210 // Add the BaseHeap's pages to the orphanedPagePool.
211 for (BasePage* page = m_firstPage; page; page = page->next()) { 211 for (BasePage* page = m_firstPage; page; page = page->next()) {
212 Heap::decreaseAllocatedSpace(page->size()); 212 Heap::decreaseAllocatedSpace(page->size());
213 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page); 213 Heap::orphanedPagePool()->addOrphanedPage(heapIndex(), page);
214 } 214 }
215 m_firstPage = nullptr; 215 m_firstPage = nullptr;
216 } 216 }
217 217
218 void BaseHeap::takeSnapshot(const String& dumpBaseName) 218 void BaseHeap::takeSnapshot(const String& dumpBaseName)
219 { 219 {
220 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
haraken 2015/05/29 02:11:30 I'm just curious but does the place we create the
Primiano Tucci (use gerrit) 2015/05/29 08:32:50 Do you mean the order or the call site? The order
ssid 2015/05/29 10:57:19 Just had a chat with primiano@. It is not necessar
220 size_t pageCount = 0; 221 size_t pageCount = 0;
221 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 222 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
223 page->takeSnapshot(dumpBaseName, pageCount);
haraken 2015/05/29 02:11:30 pageCount => pageIndex
ssid 2015/05/29 10:57:19 Done.
ssid 2015/05/29 10:57:19 Done.
222 pageCount++; 224 pageCount++;
223 } 225 }
224 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpBaseName);
225 allocatorDump->AddScalar("blink_page_count", "objects", pageCount); 226 allocatorDump->AddScalar("blink_page_count", "objects", pageCount);
226 } 227 }
227 228
228 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) 229 #if ENABLE(ASSERT) || ENABLE(GC_PROFILING)
229 BasePage* BaseHeap::findPageFromAddress(Address address) 230 BasePage* BaseHeap::findPageFromAddress(Address address)
230 { 231 {
231 for (BasePage* page = m_firstPage; page; page = page->next()) { 232 for (BasePage* page = m_firstPage; page; page = page->next()) {
232 if (page->contains(address)) 233 if (page->contains(address))
233 return page; 234 return page;
234 } 235 }
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 // cross thread pointer usage. 1388 // cross thread pointer usage.
1388 #if defined(ADDRESS_SANITIZER) 1389 #if defined(ADDRESS_SANITIZER)
1389 // This needs to zap poisoned memory as well. 1390 // This needs to zap poisoned memory as well.
1390 // Force unpoison memory before memset. 1391 // Force unpoison memory before memset.
1391 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); 1392 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize());
1392 #endif 1393 #endif
1393 memset(payload(), orphanedZapValue, payloadSize()); 1394 memset(payload(), orphanedZapValue, payloadSize());
1394 BasePage::markOrphaned(); 1395 BasePage::markOrphaned();
1395 } 1396 }
1396 1397
1398 void NormalPage::takeSnapshot(const String& dumpBaseName, size_t pageIndex)
1399 {
1400 String pageName = dumpBaseName.isolatedCopy();
haraken 2015/05/29 02:11:30 Instead of passing const String& and calling isola
Primiano Tucci (use gerrit) 2015/05/29 08:32:50 +1
1401 pageName.append(String::format("/page_%zu", pageIndex));
1402 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(pageName);
1403
1404 HeapObjectHeader* header = nullptr;
1405 size_t objectCount = 0;
1406 size_t liveCount = 0;
1407 size_t deadCount = 0;
1408 size_t freeCount = 0;
1409 size_t liveSize = 0;
1410 size_t deadSize = 0;
1411 size_t freeSize = 0;
1412 for (Address addr = payload(); addr < payloadEnd(); addr += header->size()) {
haraken 2015/05/29 02:11:30 addr => headerAddress
ssid 2015/05/29 10:57:19 Done.
1413 header = reinterpret_cast<HeapObjectHeader*>(addr);
1414 objectCount++;
1415 if (header->isFree()) {
1416 freeCount++;
1417 freeSize += header->size();
1418 } else if (header->isMarked()) {
1419 liveCount++;
1420 liveSize += header->size();
1421 } else {
1422 deadCount++;
1423 deadSize += header->size();
1424 }
1425 }
1426
1427 pageDump->AddScalar("object_count", "objects", objectCount);
haraken 2015/05/29 02:11:30 Remove objectCount. The freed area is not an objec
ssid 2015/05/29 10:57:19 Done, thanks.
1428 pageDump->AddScalar("live_count", "objects", liveCount);
1429 pageDump->AddScalar("dead_count", "objects", deadCount);
1430 pageDump->AddScalar("free_count", "objects", freeCount);
1431 pageDump->AddScalar("live_size", "bytes", liveSize);
1432 pageDump->AddScalar("dead_size", "bytes", deadSize);
1433 pageDump->AddScalar("free_size", "bytes", freeSize);
1434 }
1435
1397 #if ENABLE(GC_PROFILING) 1436 #if ENABLE(GC_PROFILING)
1398 const GCInfo* NormalPage::findGCInfo(Address address) 1437 const GCInfo* NormalPage::findGCInfo(Address address)
1399 { 1438 {
1400 if (address < payload()) 1439 if (address < payload())
1401 return nullptr; 1440 return nullptr;
1402 1441
1403 HeapObjectHeader* header = findHeaderFromAddress(address); 1442 HeapObjectHeader* header = findHeaderFromAddress(address);
1404 if (!header) 1443 if (!header)
1405 return nullptr; 1444 return nullptr;
1406 1445
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 } 1602 }
1564 1603
1565 void LargeObjectPage::markOrphaned() 1604 void LargeObjectPage::markOrphaned()
1566 { 1605 {
1567 // Zap the payload with a recognizable value to detect any incorrect 1606 // Zap the payload with a recognizable value to detect any incorrect
1568 // cross thread pointer usage. 1607 // cross thread pointer usage.
1569 memset(payload(), orphanedZapValue, payloadSize()); 1608 memset(payload(), orphanedZapValue, payloadSize());
1570 BasePage::markOrphaned(); 1609 BasePage::markOrphaned();
1571 } 1610 }
1572 1611
1612 void LargeObjectPage::takeSnapshot(const String& dumpBaseName, size_t pageIndex)
1613 {
1614 String pageName = dumpBaseName.isolatedCopy();
1615 pageName.append(String::format("/page_%zu", pageIndex));
1616 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(pageName);
1617
1618 size_t liveSize = 0;
1619 size_t deadSize = 0;
1620 size_t liveCount = 0;
1621 size_t deadCount = 0;
1622 HeapObjectHeader* header = heapObjectHeader();
1623 if (header->isMarked()) {
1624 liveCount = 1;
1625 liveSize += header->size();
1626 } else {
1627 deadCount = 1;
1628 deadSize += header->size();
1629 }
1630
1631 pageDump->AddScalar("object_count", "objects", 1u);
haraken 2015/05/29 02:11:30 Remove this.
ssid 2015/05/29 10:57:19 Done.
1632 pageDump->AddScalar("live_count", "objects", liveCount);
1633 pageDump->AddScalar("dead_count", "objects", deadCount);
1634 pageDump->AddScalar("live_size", "bytes", liveSize);
1635 pageDump->AddScalar("dead_size", "bytes", deadSize);
1636 }
1637
1573 #if ENABLE(GC_PROFILING) 1638 #if ENABLE(GC_PROFILING)
1574 const GCInfo* LargeObjectPage::findGCInfo(Address address) 1639 const GCInfo* LargeObjectPage::findGCInfo(Address address)
1575 { 1640 {
1576 if (!containedInObjectPayload(address)) 1641 if (!containedInObjectPayload(address))
1577 return nullptr; 1642 return nullptr;
1578 HeapObjectHeader* header = heapObjectHeader(); 1643 HeapObjectHeader* header = heapObjectHeader();
1579 return Heap::gcInfo(header->gcInfoIndex()); 1644 return Heap::gcInfo(header->gcInfoIndex());
1580 } 1645 }
1581 1646
1582 void LargeObjectPage::snapshot(TracedValue* json, ThreadState::SnapshotInfo* inf o) 1647 void LargeObjectPage::snapshot(TracedValue* json, ThreadState::SnapshotInfo* inf o)
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 size_t Heap::s_allocatedObjectSize = 0; 2371 size_t Heap::s_allocatedObjectSize = 0;
2307 size_t Heap::s_allocatedSpace = 0; 2372 size_t Heap::s_allocatedSpace = 0;
2308 size_t Heap::s_markedObjectSize = 0; 2373 size_t Heap::s_markedObjectSize = 0;
2309 // We don't want to use 0 KB for the initial value because it may end up 2374 // We don't want to use 0 KB for the initial value because it may end up
2310 // triggering the first GC of some thread too prematurely. 2375 // triggering the first GC of some thread too prematurely.
2311 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; 2376 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024;
2312 size_t Heap::s_externalObjectSizeAtLastGC = 0; 2377 size_t Heap::s_externalObjectSizeAtLastGC = 0;
2313 double Heap::s_estimatedMarkingTimePerByte = 0.0; 2378 double Heap::s_estimatedMarkingTimePerByte = 0.0;
2314 2379
2315 } // namespace blink 2380 } // 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