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

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 name. Created 5 years, 7 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
« Source/platform/heap/Heap.h ('K') | « 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);
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);
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 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 // cross thread pointer usage. 1340 // cross thread pointer usage.
1340 #if defined(ADDRESS_SANITIZER) 1341 #if defined(ADDRESS_SANITIZER)
1341 // This needs to zap poisoned memory as well. 1342 // This needs to zap poisoned memory as well.
1342 // Force unpoison memory before memset. 1343 // Force unpoison memory before memset.
1343 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); 1344 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize());
1344 #endif 1345 #endif
1345 memset(payload(), orphanedZapValue, payloadSize()); 1346 memset(payload(), orphanedZapValue, payloadSize());
1346 BasePage::markOrphaned(); 1347 BasePage::markOrphaned();
1347 } 1348 }
1348 1349
1350 void NormalPage::takeSnapshot(const String& dumpBaseName, size_t pageIndex)
1351 {
1352 String pageName = dumpBaseName.isolatedCopy();
1353 pageName.append(String::format("/page_%zu", pageIndex));
Primiano Tucci (use gerrit) 2015/05/28 12:47:00 maybe this is a bit more clear and efficient if yo
ssid 2015/05/28 13:06:10 With offline discussion, this seems better.
1354 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(pageName);
1355
1356 HeapObjectHeader* header = nullptr;
1357 size_t objectCount = 0;
1358 size_t liveCount = 0;
1359 size_t deadCount = 0;
1360 size_t freeCount = 0;
1361 size_t liveSize = 0;
1362 size_t deadSize = 0;
1363 size_t freeSize = 0;
1364 size_t encodedSize = 0;
1365 for (Address addr = payload(); addr < payloadEnd(); addr += header->size()) {
1366 header = reinterpret_cast<HeapObjectHeader*>(addr);
1367 objectCount++;
1368 encodedSize += header->encodedSize();
Primiano Tucci (use gerrit) 2015/05/28 12:47:00 as above, let's remove this.
ssid 2015/05/28 13:06:10 Done.
1369 if (header->isFree()) {
1370 freeCount++;
1371 freeSize += header->size();
1372 } else if (header->isMarked()) {
1373 liveCount++;
1374 liveSize += header->size();
1375 } else {
1376 deadCount++;
1377 deadSize += header->size();
1378 }
1379 }
1380
1381 pageDump->AddScalar("object_count", "objects", objectCount);
1382 pageDump->AddScalar("encoded_size", "bytes", encodedSize);
1383 pageDump->AddScalar("live_count", "objects", liveCount);
1384 pageDump->AddScalar("dead_count", "objects", deadCount);
1385 pageDump->AddScalar("free_count", "objects", freeCount);
1386 pageDump->AddScalar("live_size", "bytes", liveSize);
1387 pageDump->AddScalar("dead_size", "bytes", deadSize);
1388 pageDump->AddScalar("free_size", "bytes", freeSize);
1389 }
1390
1349 #if ENABLE(GC_PROFILING) 1391 #if ENABLE(GC_PROFILING)
1350 const GCInfo* NormalPage::findGCInfo(Address address) 1392 const GCInfo* NormalPage::findGCInfo(Address address)
1351 { 1393 {
1352 if (address < payload()) 1394 if (address < payload())
1353 return nullptr; 1395 return nullptr;
1354 1396
1355 HeapObjectHeader* header = findHeaderFromAddress(address); 1397 HeapObjectHeader* header = findHeaderFromAddress(address);
1356 if (!header) 1398 if (!header)
1357 return nullptr; 1399 return nullptr;
1358 1400
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 } 1548 }
1507 1549
1508 void LargeObjectPage::markOrphaned() 1550 void LargeObjectPage::markOrphaned()
1509 { 1551 {
1510 // Zap the payload with a recognizable value to detect any incorrect 1552 // Zap the payload with a recognizable value to detect any incorrect
1511 // cross thread pointer usage. 1553 // cross thread pointer usage.
1512 memset(payload(), orphanedZapValue, payloadSize()); 1554 memset(payload(), orphanedZapValue, payloadSize());
1513 BasePage::markOrphaned(); 1555 BasePage::markOrphaned();
1514 } 1556 }
1515 1557
1558 void LargeObjectPage::takeSnapshot(const String& dumpBaseName, size_t pageIndex)
1559 {
1560 String pageName = dumpBaseName.isolatedCopy();
1561 pageName.append(String::format("/page_%zu", pageIndex));
Primiano Tucci (use gerrit) 2015/05/28 12:47:00 ditto here
ssid 2015/05/28 13:06:10 ditto.
1562 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(pageName);
1563
1564 size_t liveSize = 0;
1565 size_t deadSize = 0;
1566 size_t liveCount = 0;
1567 size_t deadCount = 0;
1568 HeapObjectHeader* header = heapObjectHeader();
1569 if (header->isMarked()) {
1570 liveCount = 1;
1571 liveSize += header->size();
1572 } else {
1573 deadCount = 1;
1574 deadSize += header->size();
1575 }
1576
1577 pageDump->AddScalar("object_count", "objects", 1u);
1578 pageDump->AddScalar("live_count", "objects", liveCount);
1579 pageDump->AddScalar("dead_count", "objects", deadCount);
1580 pageDump->AddScalar("live_size", "bytes", liveSize);
1581 pageDump->AddScalar("dead_size", "bytes", deadSize);
1582 pageDump->AddScalar("free_size", "bytes", 0u);
Primiano Tucci (use gerrit) 2015/05/28 12:47:00 Don't dump these if you know that they don't apply
ssid 2015/05/28 13:06:09 Done.
1583 pageDump->AddScalar("free_count", "objects", 0u);
1584 }
1585
1516 #if ENABLE(GC_PROFILING) 1586 #if ENABLE(GC_PROFILING)
1517 const GCInfo* LargeObjectPage::findGCInfo(Address address) 1587 const GCInfo* LargeObjectPage::findGCInfo(Address address)
1518 { 1588 {
1519 if (!containedInObjectPayload(address)) 1589 if (!containedInObjectPayload(address))
1520 return nullptr; 1590 return nullptr;
1521 HeapObjectHeader* header = heapObjectHeader(); 1591 HeapObjectHeader* header = heapObjectHeader();
1522 return Heap::gcInfo(header->gcInfoIndex()); 1592 return Heap::gcInfo(header->gcInfoIndex());
1523 } 1593 }
1524 1594
1525 void LargeObjectPage::snapshot(TracedValue* json, ThreadState::SnapshotInfo* inf o) 1595 void LargeObjectPage::snapshot(TracedValue* json, ThreadState::SnapshotInfo* inf o)
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 size_t Heap::s_allocatedObjectSize = 0; 2315 size_t Heap::s_allocatedObjectSize = 0;
2246 size_t Heap::s_allocatedSpace = 0; 2316 size_t Heap::s_allocatedSpace = 0;
2247 size_t Heap::s_markedObjectSize = 0; 2317 size_t Heap::s_markedObjectSize = 0;
2248 // We don't want to use 0 KB for the initial value because it may end up 2318 // We don't want to use 0 KB for the initial value because it may end up
2249 // triggering the first GC of some thread too prematurely. 2319 // triggering the first GC of some thread too prematurely.
2250 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; 2320 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024;
2251 size_t Heap::s_externalObjectSizeAtLastGC = 0; 2321 size_t Heap::s_externalObjectSizeAtLastGC = 0;
2252 double Heap::s_estimatedMarkingTimePerByte = 0.0; 2322 double Heap::s_estimatedMarkingTimePerByte = 0.0;
2253 2323
2254 } // namespace blink 2324 } // namespace blink
OLDNEW
« Source/platform/heap/Heap.h ('K') | « Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698