Skip to content
Permalink
Browse files
[Cocoa] ResourceUsageOverlay should query kernel for VM page size.
<https://webkit.org/b/151920>

Reviewed by Andy Estes.

Read the vm.pagesize sysctl to find the correct page size for memory usage calculations.
This fixes broken math on systems that have different hw.pagesize and vm.pagesize.

* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::vmPageSize):
(WebCore::pagesPerVMTag):
(WebCore::runSamplerThread):


Canonical link: https://commits.webkit.org/170144@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193757 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Dec 8, 2015
1 parent bb28229 commit f74af3636e9e3dba591e58f23b9d6b7cef7fb6b2
Showing with 33 additions and 6 deletions.
  1. +15 −0 Source/WebCore/ChangeLog
  2. +18 −6 Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm
@@ -1,3 +1,18 @@
2015-12-08 Andreas Kling <akling@apple.com>

[Cocoa] ResourceUsageOverlay should query kernel for VM page size.
<https://webkit.org/b/151920>

Reviewed by Andy Estes.

Read the vm.pagesize sysctl to find the correct page size for memory usage calculations.
This fixes broken math on systems that have different hw.pagesize and vm.pagesize.

* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::vmPageSize):
(WebCore::pagesPerVMTag):
(WebCore::runSamplerThread):

2015-12-08 Chris Dumez <cdumez@apple.com>

Add diagnostic logging to measure speculative revalidation accuracy
@@ -38,6 +38,7 @@
#include <mach/mach.h>
#include <mach/vm_statistics.h>
#include <runtime/JSLock.h>
#include <sys/sysctl.h>
#include <thread>
#include <wtf/MathExtras.h>
#include <wtf/NeverDestroyed.h>
@@ -69,6 +70,19 @@ - (void)drawInContext:(CGContextRef)context

namespace WebCore {

static size_t vmPageSize()
{
static size_t pageSize;
static std::once_flag onceFlag;
std::call_once(onceFlag, [&] {
size_t outputSize = sizeof(pageSize);
int status = sysctlbyname("vm.pagesize", &pageSize, &outputSize, nullptr, 0);
ASSERT_UNUSED(status, status != -1);
ASSERT(pageSize);
});
return pageSize;
}

template<typename T, size_t size = 70>
class RingBuffer {
public:
@@ -459,8 +473,7 @@ static String formatByteNumber(size_t number)
}

if (purgeableState == VM_PURGABLE_EMPTY) {
static size_t vmPageSize = getpagesize();
tags[info.user_tag].reclaimable += size / vmPageSize;
tags[info.user_tag].reclaimable += size / vmPageSize();
continue;
}

@@ -533,7 +546,6 @@ static unsigned categoryForVMTag(unsigned tag)

NO_RETURN void runSamplerThread(void*)
{
static size_t vmPageSize = getpagesize();
auto& data = sharedData();
while (1) {
float cpu = cpuUsage();
@@ -556,10 +568,10 @@ NO_RETURN void runSamplerThread(void*)
for (auto& category : data.categories) {
if (category.isSubcategory) // Only do automatic tallying for top-level categories.
continue;
category.history.append(pagesPerCategory[category.type].dirty * vmPageSize);
category.reclaimableHistory.append(pagesPerCategory[category.type].reclaimable * vmPageSize);
category.history.append(pagesPerCategory[category.type].dirty * vmPageSize());
category.reclaimableHistory.append(pagesPerCategory[category.type].reclaimable * vmPageSize());
}
data.totalDirty.append(totalDirtyPages * vmPageSize);
data.totalDirty.append(totalDirtyPages * vmPageSize());

copyToVector(data.overlayLayers, layers);

0 comments on commit f74af36

Please sign in to comment.