Changeset 192595 in webkit
- Timestamp:
- Nov 18, 2015, 3:48:48 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r192592 r192595 1 2015-11-18 Andreas Kling <akling@apple.com> 2 3 ResourceUsageOverlay should have better accounting for reclaimable memory. 4 <https://webkit.org/b/151407> 5 6 Reviewed by Anders Carlsson. 7 8 Add code to inspect the purgeable state of VM regions when traversing the 9 web process VM map, and track reclaimable regions of memory separately. 10 11 Memory categories that have some amount of reclaimable memory are now 12 displayed with the reclaimable amount in brackets, e.g "123.45 MB [56.78MB]" 13 14 * page/ResourceUsageOverlay.h: 15 * page/cocoa/ResourceUsageOverlayCocoa.mm: 16 (WebCore::ResourceUsageOverlay::platformDraw): 17 (WebCore::TagInfo::TagInfo): 18 (WebCore::pagesPerVMTag): 19 (WebCore::runSamplerThread): 20 (WebCore::dirtyPagesPerVMTag): Deleted. 21 1 22 2015-11-18 Joseph Pecoraro <pecoraro@apple.com> 2 23 -
trunk/Source/WebCore/page/ResourceUsageOverlay.h
r192056 r192595 82 82 #endif 83 83 84 static const int normalWidth = 5 50;84 static const int normalWidth = 570; 85 85 static const int normalHeight = 130; 86 86 }; -
trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm
r192056 r192595 147 147 RetainPtr<CGColorRef> color; 148 148 RingBuffer<size_t> history; 149 RingBuffer<size_t> reclaimableHistory; 149 150 bool isSubcategory { false }; 150 151 unsigned type { MemoryCategory::NumberOfCategories }; … … 412 413 float y = 50; 413 414 for (auto& category : data.categories) { 415 String label = String::format("% 11s: %s", category.name.ascii().data(), formatByteNumber(category.history.last()).ascii().data()); 416 size_t reclaimable = category.reclaimableHistory.last(); 417 if (reclaimable) 418 label = label + String::format(" [%s]", formatByteNumber(reclaimable).ascii().data()); 419 414 420 // FIXME: Show size/capacity of GC heap. 415 showText(context, 10, y, category.color.get(), String::format("% 11s: %s", category.name.ascii().data(), formatByteNumber(category.history.last()).ascii().data()));421 showText(context, 10, y, category.color.get(), label); 416 422 y += 10; 417 423 } … … 425 431 } 426 432 427 static std::array<size_t, 256> dirtyPagesPerVMTag() 428 { 429 std::array<size_t, 256> dirty; 430 dirty.fill(0); 433 struct TagInfo { 434 TagInfo() { } 435 size_t dirty { 0 }; 436 size_t reclaimable { 0 }; 437 }; 438 439 static std::array<TagInfo, 256> pagesPerVMTag() 440 { 441 std::array<TagInfo, 256> tags; 431 442 task_t task = mach_task_self(); 432 443 mach_vm_size_t size; … … 435 446 mach_msg_type_number_t count = VM_REGION_SUBMAP_INFO_COUNT_64; 436 447 for (mach_vm_address_t addr = 0; ; addr += size) { 448 int purgeableState; 449 if (mach_vm_purgable_control(task, addr, VM_PURGABLE_GET_STATE, &purgeableState) != KERN_SUCCESS) 450 purgeableState = VM_PURGABLE_DENY; 451 437 452 kern_return_t kr = mach_vm_region_recurse(task, &addr, &size, &depth, (vm_region_info_t)&info, &count); 438 453 if (kr != KERN_SUCCESS) 439 454 break; 440 dirty[info.user_tag] += info.pages_dirtied; 441 } 442 return dirty; 455 456 if (purgeableState == VM_PURGABLE_VOLATILE) { 457 tags[info.user_tag].reclaimable += info.pages_resident; 458 continue; 459 } 460 461 if (purgeableState == VM_PURGABLE_EMPTY) { 462 static size_t vmPageSize = getpagesize(); 463 tags[info.user_tag].reclaimable += size / vmPageSize; 464 continue; 465 } 466 467 bool anonymous = !info.external_pager; 468 if (anonymous) { 469 tags[info.user_tag].dirty += info.pages_resident - info.pages_reusable; 470 tags[info.user_tag].reclaimable += info.pages_reusable; 471 } else 472 tags[info.user_tag].dirty += info.pages_dirtied; 473 } 474 475 return tags; 443 476 } 444 477 … … 505 538 while (1) { 506 539 float cpu = cpuUsage(); 507 auto dirtyPages = dirtyPagesPerVMTag();540 auto tags = pagesPerVMTag(); 508 541 Vector<CALayer *, 8> layers; 509 542 … … 512 545 data.cpuHistory.append(cpu); 513 546 514 std::array<size_t, MemoryCategory::NumberOfCategories> dirtyPagesPerCategory; 515 dirtyPagesPerCategory.fill(0); 547 std::array<TagInfo, MemoryCategory::NumberOfCategories> pagesPerCategory; 516 548 517 549 size_t totalDirtyPages = 0; 518 550 for (unsigned i = 0; i < 256; ++i) { 519 dirtyPagesPerCategory[categoryForVMTag(i)] += dirtyPages[i]; 520 totalDirtyPages += dirtyPages[i]; 551 pagesPerCategory[categoryForVMTag(i)].dirty += tags[i].dirty; 552 pagesPerCategory[categoryForVMTag(i)].reclaimable += tags[i].reclaimable; 553 totalDirtyPages += tags[i].dirty; 521 554 } 522 555 … … 524 557 if (category.isSubcategory) // Only do automatic tallying for top-level categories. 525 558 continue; 526 category.history.append(dirtyPagesPerCategory[category.type] * vmPageSize); 559 category.history.append(pagesPerCategory[category.type].dirty * vmPageSize); 560 category.reclaimableHistory.append(pagesPerCategory[category.type].reclaimable * vmPageSize); 527 561 } 528 562 data.totalDirty.append(totalDirtyPages * vmPageSize);
Note:
See TracChangeset
for help on using the changeset viewer.