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

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

Issue 1200833008: Adding freelist statistics to blink gc dump provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@oilpan_n2
Patch Set: Nits. 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
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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 sweepUnsweptPage(); 512 sweepUnsweptPage();
513 } 513 }
514 } 514 }
515 515
516 NormalPageHeap::NormalPageHeap(ThreadState* state, int index) 516 NormalPageHeap::NormalPageHeap(ThreadState* state, int index)
517 : BaseHeap(state, index) 517 : BaseHeap(state, index)
518 , m_currentAllocationPoint(nullptr) 518 , m_currentAllocationPoint(nullptr)
519 , m_remainingAllocationSize(0) 519 , m_remainingAllocationSize(0)
520 , m_lastRemainingAllocationSize(0) 520 , m_lastRemainingAllocationSize(0)
521 , m_promptlyFreedSize(0) 521 , m_promptlyFreedSize(0)
522 #if ENABLE(GC_PROFILING)
523 , m_cumulativeAllocationSize(0) 522 , m_cumulativeAllocationSize(0)
524 , m_allocationCount(0) 523 , m_allocationCount(0)
525 , m_inlineAllocationCount(0) 524 , m_inlineAllocationCount(0)
526 #endif
527 { 525 {
528 clearFreeLists(); 526 clearFreeLists();
529 } 527 }
530 528
531 void NormalPageHeap::clearFreeLists() 529 void NormalPageHeap::clearFreeLists()
532 { 530 {
533 setAllocationPoint(nullptr, 0); 531 setAllocationPoint(nullptr, 0);
534 m_freeList.clear(); 532 m_freeList.clear();
535 } 533 }
536 534
(...skipping 18 matching lines...) Expand all
555 bool NormalPageHeap::pagesToBeSweptContains(Address address) 553 bool NormalPageHeap::pagesToBeSweptContains(Address address)
556 { 554 {
557 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) { 555 for (BasePage* page = m_firstUnsweptPage; page; page = page->next()) {
558 if (page->contains(address)) 556 if (page->contains(address))
559 return true; 557 return true;
560 } 558 }
561 return false; 559 return false;
562 } 560 }
563 #endif 561 #endif
564 562
563 void NormalPageHeap::takeFreelistSnapshot(String dumpName)
564 {
565 dumpName.append("/buckets");
566 WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance( )->createMemoryAllocatorDumpForCurrentGC(dumpName);
567 allocatorDump->AddScalar("cumulative_allocation_size", "bytes", m_cumulative AllocationSize);
568 allocatorDump->AddScalarF("inline_allocation_rate", static_cast<double>(m_in lineAllocationCount) / m_allocationCount);
569 allocatorDump->AddScalar("inline_allocation_count", "objects", m_inlineAlloc ationCount);
570 allocatorDump->AddScalar("allocation_count", "objects", m_allocationCount);
571
572 m_freeList.takeSnapshot(dumpName);
573 }
574
565 #if ENABLE(GC_PROFILING) 575 #if ENABLE(GC_PROFILING)
566 void NormalPageHeap::snapshotFreeList(TracedValue& json) 576 void NormalPageHeap::snapshotFreeList(TracedValue& json)
567 { 577 {
568 json.setInteger("cumulativeAllocationSize", m_cumulativeAllocationSize); 578 json.setInteger("cumulativeAllocationSize", m_cumulativeAllocationSize);
569 json.setDouble("inlineAllocationRate", static_cast<double>(m_inlineAllocatio nCount) / m_allocationCount); 579 json.setDouble("inlineAllocationRate", static_cast<double>(m_inlineAllocatio nCount) / m_allocationCount);
570 json.setInteger("inlineAllocationCount", m_inlineAllocationCount); 580 json.setInteger("inlineAllocationCount", m_inlineAllocationCount);
571 json.setInteger("allocationCount", m_allocationCount); 581 json.setInteger("allocationCount", m_allocationCount);
572 size_t pageCount = 0; 582 size_t pageCount = 0;
573 size_t totalPageSize = 0; 583 size_t totalPageSize = 0;
574 for (NormalPage* page = static_cast<NormalPage*>(m_firstPage); page; page = static_cast<NormalPage*>(page->next())) { 584 for (NormalPage* page = static_cast<NormalPage*>(m_firstPage); page; page = static_cast<NormalPage*>(page->next())) {
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 { 1123 {
1114 ASSERT(size > 0); 1124 ASSERT(size > 0);
1115 int index = -1; 1125 int index = -1;
1116 while (size) { 1126 while (size) {
1117 size >>= 1; 1127 size >>= 1;
1118 index++; 1128 index++;
1119 } 1129 }
1120 return index; 1130 return index;
1121 } 1131 }
1122 1132
1133 void FreeList::takeSnapshot(const String& dumpBaseName)
1134 {
1135 for (size_t i = 0; i < blinkPageSizeLog2; ++i) {
1136 size_t entryCount = 0;
1137 size_t freeSize = 0;
1138 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) {
1139 ++entryCount;
1140 freeSize += entry->size();
1141 }
1142
1143 String dumpName = dumpBaseName.isolatedCopy();
haraken 2015/06/23 05:38:58 Shall we pass in a String to takeSnapshot and avoi
ssid 2015/06/23 06:03:39 hm, This is inside the for loop. I can't find a be
haraken 2015/06/23 06:24:24 For string append, we're encouraged to use StringB
ssid 2015/06/23 07:39:56 Sorry, i just realized it has a + operator, though
1144 dumpName.append(String::format("/bucket_%lu", static_cast<unsigned long> (i)));
haraken 2015/06/23 05:38:58 It would be more informative to use 2^i instead of
ssid 2015/06/23 07:39:56 Done.
1145 WebMemoryAllocatorDump* bucketDump = BlinkGCMemoryDumpProvider::instance ()->createMemoryAllocatorDumpForCurrentGC(dumpName);
1146 bucketDump->AddScalar("freelist_entry_count", "objects", entryCount);
1147 bucketDump->AddScalar("free_size", "bytes", freeSize);
1148 }
1149 }
1150
1123 #if ENABLE(GC_PROFILING) 1151 #if ENABLE(GC_PROFILING)
1124 void FreeList::getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& to talFreeSize) const 1152 void FreeList::getFreeSizeStats(PerBucketFreeListStats bucketStats[], size_t& to talFreeSize) const
1125 { 1153 {
1126 totalFreeSize = 0; 1154 totalFreeSize = 0;
1127 for (size_t i = 0; i < blinkPageSizeLog2; i++) { 1155 for (size_t i = 0; i < blinkPageSizeLog2; i++) {
1128 size_t& entryCount = bucketStats[i].entryCount; 1156 size_t& entryCount = bucketStats[i].entryCount;
1129 size_t& freeSize = bucketStats[i].freeSize; 1157 size_t& freeSize = bucketStats[i].freeSize;
1130 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) { 1158 for (FreeListEntry* entry = m_freeLists[i]; entry; entry = entry->next() ) {
1131 ++entryCount; 1159 ++entryCount;
1132 freeSize += entry->size(); 1160 freeSize += entry->size();
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 // This needs to zap poisoned memory as well. 1474 // This needs to zap poisoned memory as well.
1447 // Force unpoison memory before memset. 1475 // Force unpoison memory before memset.
1448 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize()); 1476 ASAN_UNPOISON_MEMORY_REGION(payload(), payloadSize());
1449 #endif 1477 #endif
1450 memset(payload(), orphanedZapValue, payloadSize()); 1478 memset(payload(), orphanedZapValue, payloadSize());
1451 BasePage::markOrphaned(); 1479 BasePage::markOrphaned();
1452 } 1480 }
1453 1481
1454 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex) 1482 void NormalPage::takeSnapshot(String dumpName, size_t pageIndex)
1455 { 1483 {
1456 dumpName.append(String::format("/page_%lu", static_cast<unsigned long>(pageI ndex))); 1484 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex)));
1457 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); 1485 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName);
1458 1486
1459 HeapObjectHeader* header = nullptr; 1487 HeapObjectHeader* header = nullptr;
1460 size_t liveCount = 0; 1488 size_t liveCount = 0;
1461 size_t deadCount = 0; 1489 size_t deadCount = 0;
1462 size_t freeCount = 0; 1490 size_t freeCount = 0;
1463 size_t liveSize = 0; 1491 size_t liveSize = 0;
1464 size_t deadSize = 0; 1492 size_t deadSize = 0;
1465 size_t freeSize = 0; 1493 size_t freeSize = 0;
1466 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header Address += header->size()) { 1494 for (Address headerAddress = payload(); headerAddress < payloadEnd(); header Address += header->size()) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 void LargeObjectPage::markOrphaned() 1683 void LargeObjectPage::markOrphaned()
1656 { 1684 {
1657 // Zap the payload with a recognizable value to detect any incorrect 1685 // Zap the payload with a recognizable value to detect any incorrect
1658 // cross thread pointer usage. 1686 // cross thread pointer usage.
1659 memset(payload(), orphanedZapValue, payloadSize()); 1687 memset(payload(), orphanedZapValue, payloadSize());
1660 BasePage::markOrphaned(); 1688 BasePage::markOrphaned();
1661 } 1689 }
1662 1690
1663 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex) 1691 void LargeObjectPage::takeSnapshot(String dumpName, size_t pageIndex)
1664 { 1692 {
1665 dumpName.append(String::format("/page_%lu", static_cast<unsigned long>(pageI ndex))); 1693 dumpName.append(String::format("/pages/page_%lu", static_cast<unsigned long> (pageIndex)));
1666 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName); 1694 WebMemoryAllocatorDump* pageDump = BlinkGCMemoryDumpProvider::instance()->cr eateMemoryAllocatorDumpForCurrentGC(dumpName);
1667 1695
1668 size_t liveSize = 0; 1696 size_t liveSize = 0;
1669 size_t deadSize = 0; 1697 size_t deadSize = 0;
1670 size_t liveCount = 0; 1698 size_t liveCount = 0;
1671 size_t deadCount = 0; 1699 size_t deadCount = 0;
1672 HeapObjectHeader* header = heapObjectHeader(); 1700 HeapObjectHeader* header = heapObjectHeader();
1673 if (header->isMarked()) { 1701 if (header->isMarked()) {
1674 liveCount = 1; 1702 liveCount = 1;
1675 liveSize += header->size(); 1703 liveSize += header->size();
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 size_t Heap::s_allocatedObjectSize = 0; 2423 size_t Heap::s_allocatedObjectSize = 0;
2396 size_t Heap::s_allocatedSpace = 0; 2424 size_t Heap::s_allocatedSpace = 0;
2397 size_t Heap::s_markedObjectSize = 0; 2425 size_t Heap::s_markedObjectSize = 0;
2398 // We don't want to use 0 KB for the initial value because it may end up 2426 // We don't want to use 0 KB for the initial value because it may end up
2399 // triggering the first GC of some thread too prematurely. 2427 // triggering the first GC of some thread too prematurely.
2400 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; 2428 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024;
2401 size_t Heap::s_externalObjectSizeAtLastGC = 0; 2429 size_t Heap::s_externalObjectSizeAtLastGC = 0;
2402 double Heap::s_estimatedMarkingTimePerByte = 0.0; 2430 double Heap::s_estimatedMarkingTimePerByte = 0.0;
2403 2431
2404 } // namespace blink 2432 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698