Skip to content

Commit

Permalink
[PlayStation] Web Inspector: add memory usage of page in memory timeline
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=255642

Reviewed by Basuke Suzuki.

Currently, the inspector backend of playstation only aggregates the size of GCHeap.
This change adds the usage of page category to memory details in timeline tab.

* Source/WebCore/PlatformPlayStation.cmake:
* Source/WebCore/page/playstation/ResourceUsageThreadPlayStation.cpp:
(WebCore::ResourceUsageThread::platformCollectMemoryData):

Canonical link: https://commits.webkit.org/263405@main
  • Loading branch information
haruhisa-shin authored and basuke committed Apr 26, 2023
1 parent f462028 commit d93e32a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Source/WebCore/PlatformPlayStation.cmake
Expand Up @@ -145,4 +145,10 @@ if (USE_WPE_BACKEND_PLAYSTATION)
list(APPEND WebCore_MODULES WPE)
endif ()

find_library(SHOWMAP_LIB showmap)
list(APPEND WebCore_LIBRARIES ${SHOWMAP_LIB})

find_path(SHOWMAP_INCLUDE_DIR NAMES showmap.h)
list(APPEND WebCore_INCLUDE_DIRECTORIES ${SHOWMAP_INCLUDE_DIR})

PLAYSTATION_COPY_MODULES(WebCore TARGETS ${WebCore_MODULES})
32 changes: 24 additions & 8 deletions Source/WebCore/page/playstation/ResourceUsageThreadPlayStation.cpp
Expand Up @@ -30,6 +30,7 @@

#include <JavaScriptCore/GCActivityCallback.h>
#include <JavaScriptCore/VM.h>
#include <showmap.h>

namespace WebCore {

Expand All @@ -55,17 +56,32 @@ void ResourceUsageThread::platformCollectCPUData(JSC::VM*, ResourceUsageData& da

void ResourceUsageThread::platformCollectMemoryData(JSC::VM* vm, ResourceUsageData& data)
{
// FIXME: Calculate total dirty memory size for ResourceUsageOverlay
data.totalDirtySize = 0;
auto& categories = data.categories;

size_t currentGCHeapCapacity = vm->heap.blockBytesAllocated();
size_t currentGCOwnedExtra = vm->heap.extraMemorySize();
size_t currentGCOwnedExternal = vm->heap.externalMemorySize();
auto currentGCHeapCapacity = vm->heap.blockBytesAllocated();
auto currentGCOwnedExtra = vm->heap.extraMemorySize();
auto currentGCOwnedExternal = vm->heap.externalMemorySize();
RELEASE_ASSERT(currentGCOwnedExternal <= currentGCOwnedExtra);

data.categories[MemoryCategory::GCHeap].dirtySize = currentGCHeapCapacity;
data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwnedExtra - currentGCOwnedExternal;
data.categories[MemoryCategory::GCOwned].externalSize = currentGCOwnedExternal;
categories[MemoryCategory::GCHeap].dirtySize = currentGCHeapCapacity;
categories[MemoryCategory::GCOwned].dirtySize = currentGCOwnedExtra - currentGCOwnedExternal;
categories[MemoryCategory::GCOwned].externalSize = currentGCOwnedExternal;

auto currentGCDirtySize = currentGCHeapCapacity + currentGCOwnedExtra - currentGCOwnedExternal;

// TODO: collect dirty size of "MemoryCategory::Images" and "MemoryCategory::Layers"

showmap::Result<256> result;
result.collect();
data.totalDirtySize = result.effectiveRss();

if (auto* entry = result.entry("SceNKFastMalloc")) {
auto rss = entry->effectiveRss();
RELEASE_ASSERT(data.totalDirtySize > rss);
categories[MemoryCategory::Other].dirtySize = data.totalDirtySize - rss;
categories[MemoryCategory::bmalloc].dirtySize = rss - std::min(rss, currentGCDirtySize);
} else
categories[MemoryCategory::Other] = data.totalDirtySize - std::min(data.totalDirtySize, currentGCDirtySize);

data.totalExternalSize = currentGCOwnedExternal;

Expand Down

0 comments on commit d93e32a

Please sign in to comment.