зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1477512: Part 3 - Add memory reporter for thread heap overhead. r=erahm
This adds reporting for heap overhead from nsThread and PRThread wrappers, as well as thread event queues. It does not, currently, include overhead from PlatformThread or js::Thread wrappers. MozReview-Commit-ID: 6DkvbbkjHXm --HG-- extra : rebase_source : 79df7172387fa1f952c43b06db644390be6f0d8a
This commit is contained in:
Родитель
7c232c3f91
Коммит
1044b14dd3
|
@ -1404,10 +1404,10 @@ public:
|
|||
};
|
||||
NS_IMPL_ISUPPORTS(AtomTablesReporter, nsIMemoryReporter)
|
||||
|
||||
#if defined(XP_LINUX) || defined(XP_WIN)
|
||||
class ThreadStacksReporter final : public nsIMemoryReporter
|
||||
class ThreadsReporter final : public nsIMemoryReporter
|
||||
{
|
||||
~ThreadStacksReporter() = default;
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
|
||||
~ThreadsReporter() = default;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -1431,12 +1431,18 @@ public:
|
|||
};
|
||||
AutoTArray<ThreadData, 32> threads;
|
||||
|
||||
size_t eventQueueSizes = 0;
|
||||
size_t wrapperSizes = 0;
|
||||
|
||||
for (auto* thread : nsThread::Enumerate()) {
|
||||
eventQueueSizes += thread->SizeOfEventQueues(MallocSizeOf);
|
||||
wrapperSizes += thread->ShallowSizeOfIncludingThis(MallocSizeOf);
|
||||
|
||||
if (!thread->StackBase()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef XP_LINUX
|
||||
#if defined(XP_LINUX)
|
||||
int idx = mappings.BinaryIndexOf(thread->StackBase());
|
||||
if (idx < 0) {
|
||||
continue;
|
||||
|
@ -1479,9 +1485,13 @@ public:
|
|||
MOZ_ASSERT(mappings[idx].Size() == thread->StackSize(),
|
||||
"Mapping region size doesn't match stack allocation size");
|
||||
#endif
|
||||
#else
|
||||
#elif defined(XP_WIN)
|
||||
auto memInfo = MemoryInfo::Get(thread->StackBase(), thread->StackSize());
|
||||
size_t privateSize = memInfo.Committed();
|
||||
#else
|
||||
size_t privateSize = thread->StackSize();
|
||||
MOZ_ASSERT_UNREACHABLE("Shouldn't have stack base pointer on this "
|
||||
"platform");
|
||||
#endif
|
||||
|
||||
threads.AppendElement(ThreadData{
|
||||
|
@ -1497,7 +1507,7 @@ public:
|
|||
}
|
||||
|
||||
for (auto& thread : threads) {
|
||||
nsPrintfCString path("explicit/thread-stacks/%s (tid=%u)",
|
||||
nsPrintfCString path("explicit/threads/stacks/%s (tid=%u)",
|
||||
thread.mName.get(), thread.mThreadId);
|
||||
|
||||
aHandleReport->Callback(
|
||||
|
@ -1509,11 +1519,20 @@ public:
|
|||
aData);
|
||||
}
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/threads/overhead/event-queues", KIND_HEAP, UNITS_BYTES,
|
||||
eventQueueSizes,
|
||||
"The sizes of nsThread event queues and observers.");
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/threads/overhead/wrappers", KIND_HEAP, UNITS_BYTES,
|
||||
wrapperSizes,
|
||||
"The sizes of nsThread/PRThread wrappers.");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
NS_IMPL_ISUPPORTS(ThreadStacksReporter, nsIMemoryReporter)
|
||||
#endif
|
||||
NS_IMPL_ISUPPORTS(ThreadsReporter, nsIMemoryReporter)
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
|
@ -1676,9 +1695,7 @@ nsMemoryReporterManager::Init()
|
|||
|
||||
RegisterStrongReporter(new AtomTablesReporter());
|
||||
|
||||
#if defined(XP_LINUX) || defined(XP_WIN)
|
||||
RegisterStrongReporter(new ThreadStacksReporter());
|
||||
#endif
|
||||
RegisterStrongReporter(new ThreadsReporter());
|
||||
|
||||
#ifdef DEBUG
|
||||
RegisterStrongReporter(new DeadlockDetectorReporter());
|
||||
|
|
Загрузка…
Ссылка в новой задаче