mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Backed out 3 changesets (bug 1822451) for busting thunderbird builds and causing bug 1825467. CLOSED TREE
Backed out changeset 5c399ec3dae0 (bug 1822451) Backed out changeset ac5d1057c562 (bug 1822451) Backed out changeset 42250977529b (bug 1822451)
This commit is contained in:
parent
be9a5c48e4
commit
f894363c34
@ -17,7 +17,7 @@
|
||||
// can decide to implement those methods or not.
|
||||
//
|
||||
// Replace-malloc libraries can provide such a bridge by implementing
|
||||
// a ReplaceMallocBridge-derived class, and a get_bridge function
|
||||
// a ReplaceMallocBridge-derived class, and a replace_get_bridge function
|
||||
// returning an instance of that class. The default methods in
|
||||
// ReplaceMallocBridge are expected to return values that callers would
|
||||
// understand as "the bridge doesn't implement this method", so that a
|
||||
@ -117,16 +117,6 @@ struct DMDFuncs;
|
||||
|
||||
namespace phc {
|
||||
class AddrInfo;
|
||||
|
||||
struct MemoryUsage {
|
||||
// The amount of memory used for PHC metadata, eg information about each
|
||||
// allocation including stacks.
|
||||
size_t mMetadataBytes = 0;
|
||||
|
||||
// The amount of memory lost due to rounding allocation sizes up to the
|
||||
// nearest page. AKA internal fragmentation.
|
||||
size_t mFragmentationBytes = 0;
|
||||
};
|
||||
} // namespace phc
|
||||
|
||||
// Callbacks to register debug file handles for Poison IO interpose.
|
||||
@ -136,10 +126,11 @@ struct DebugFdRegistry {
|
||||
|
||||
virtual void UnRegisterHandle(intptr_t aFd);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
struct ReplaceMallocBridge {
|
||||
ReplaceMallocBridge() : mVersion(5) {}
|
||||
ReplaceMallocBridge() : mVersion(4) {}
|
||||
|
||||
// This method was added in version 1 of the bridge.
|
||||
virtual mozilla::dmd::DMDFuncs* GetDMDFuncs() { return nullptr; }
|
||||
@ -191,10 +182,6 @@ struct ReplaceMallocBridge {
|
||||
// This method was added in version 4 of the bridge.
|
||||
virtual bool IsPHCEnabledOnCurrentThread() { return false; }
|
||||
|
||||
// Return PHC memory usage information by filling in the supplied structure.
|
||||
// This method was added in version 5 of the bridge.
|
||||
virtual void PHCMemoryUsage(mozilla::phc::MemoryUsage& aMemoryUsage) {}
|
||||
|
||||
# ifndef REPLACE_MALLOC_IMPL
|
||||
// Returns the replace-malloc bridge if its version is at least the
|
||||
// requested one.
|
||||
@ -262,13 +249,6 @@ struct ReplaceMalloc {
|
||||
auto singleton = ReplaceMallocBridge::Get(/* minimumVersion */ 4);
|
||||
return singleton ? singleton->IsPHCEnabledOnCurrentThread() : false;
|
||||
}
|
||||
|
||||
static void PHCMemoryUsage(mozilla::phc::MemoryUsage& aMemoryUsage) {
|
||||
auto singleton = ReplaceMallocBridge::Get(/* minimumVersion */ 5);
|
||||
if (singleton) {
|
||||
singleton->PHCMemoryUsage(aMemoryUsage);
|
||||
}
|
||||
}
|
||||
};
|
||||
# endif
|
||||
|
||||
|
@ -656,12 +656,6 @@ class GMut {
|
||||
(kPageSize - 1));
|
||||
}
|
||||
|
||||
// The internal fragmentation for this allocation.
|
||||
size_t FragmentationBytes() const {
|
||||
MOZ_ASSERT(kPageSize >= UsableSize());
|
||||
return mState == AllocPageState::InUse ? kPageSize - UsableSize() : 0;
|
||||
}
|
||||
|
||||
// The allocation stack.
|
||||
// - NeverAllocated: Nothing.
|
||||
// - InUse | Freed: Some.
|
||||
@ -725,15 +719,6 @@ class GMut {
|
||||
return page.UsableSize();
|
||||
}
|
||||
|
||||
// The total fragmentation in PHC
|
||||
size_t FragmentationBytes() const {
|
||||
size_t sum = 0;
|
||||
for (auto page : mAllocPages) {
|
||||
sum += page.FragmentationBytes();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void SetPageInUse(GMutLock aLock, uintptr_t aIndex,
|
||||
const Maybe<arena_id_t>& aArenaId, uint8_t* aBaseAddr,
|
||||
const StackTrace& aAllocStack) {
|
||||
@ -1404,11 +1389,6 @@ static size_t replace_malloc_usable_size(usable_ptr_t aPtr) {
|
||||
return gMut->PageUsableSize(lock, index);
|
||||
}
|
||||
|
||||
static size_t metadata_size() {
|
||||
return sMallocTable.malloc_usable_size(gConst) +
|
||||
sMallocTable.malloc_usable_size(gMut);
|
||||
}
|
||||
|
||||
void replace_jemalloc_stats(jemalloc_stats_t* aStats,
|
||||
jemalloc_bin_stats_t* aBinStats) {
|
||||
sMallocTable.jemalloc_stats_internal(aStats, aBinStats);
|
||||
@ -1430,20 +1410,17 @@ void replace_jemalloc_stats(jemalloc_stats_t* aStats,
|
||||
}
|
||||
aStats->allocated += allocated;
|
||||
|
||||
// guards is the gap between `allocated` and `mapped`. In some ways this
|
||||
// almost fits into aStats->wasted since it feels like wasted memory. However
|
||||
// wasted should only include committed memory and these guard pages are
|
||||
// uncommitted. Therefore we don't include it anywhere.
|
||||
// size_t guards = mapped - allocated;
|
||||
// Waste is the gap between `allocated` and `mapped`.
|
||||
size_t waste = mapped - allocated;
|
||||
aStats->waste += waste;
|
||||
|
||||
// aStats.page_cache and aStats.bin_unused are left unchanged because PHC
|
||||
// doesn't have anything corresponding to those.
|
||||
|
||||
// The metadata is stored in normal heap allocations, so they're measured by
|
||||
// gConst and gMut are normal heap allocations, so they're measured by
|
||||
// mozjemalloc as `allocated`. Move them into `bookkeeping`.
|
||||
// They're also reported under explicit/heap-overhead/phc/fragmentation in
|
||||
// about:memory.
|
||||
size_t bookkeeping = metadata_size();
|
||||
size_t bookkeeping = sMallocTable.malloc_usable_size(gConst) +
|
||||
sMallocTable.malloc_usable_size(gMut);
|
||||
aStats->allocated -= bookkeeping;
|
||||
aStats->bookkeeping += bookkeeping;
|
||||
}
|
||||
@ -1575,17 +1552,6 @@ class PHCBridge : public ReplaceMallocBridge {
|
||||
LOG("IsPHCEnabledOnCurrentThread: %zu\n", size_t(enabled));
|
||||
return enabled;
|
||||
}
|
||||
|
||||
virtual void PHCMemoryUsage(
|
||||
mozilla::phc::MemoryUsage& aMemoryUsage) override {
|
||||
aMemoryUsage.mMetadataBytes = metadata_size();
|
||||
if (gMut) {
|
||||
MutexAutoLock lock(GMut::sMutex);
|
||||
aMemoryUsage.mFragmentationBytes = gMut->FragmentationBytes();
|
||||
} else {
|
||||
aMemoryUsage.mFragmentationBytes = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// WARNING: this function runs *very* early -- before all static initializers
|
||||
|
@ -220,9 +220,6 @@ if CONFIG["OS_TARGET"] == "Linux":
|
||||
"AvailableMemoryWatcherUtils.h",
|
||||
]
|
||||
|
||||
if CONFIG["MOZ_PHC"]:
|
||||
DEFINES["MOZ_PHC"] = True
|
||||
|
||||
GeneratedFile("ErrorList.h", script="ErrorList.py", entry_point="error_list_h")
|
||||
GeneratedFile(
|
||||
"ErrorNamesInternal.h", script="ErrorList.py", entry_point="error_names_internal_h"
|
||||
|
@ -1335,25 +1335,6 @@ class JemallocHeapReporter final : public nsIMemoryReporter {
|
||||
MOZ_COLLECT_REPORT(
|
||||
"heap-chunksize", KIND_OTHER, UNITS_BYTES, stats.chunksize,
|
||||
"Size of chunks.");
|
||||
|
||||
#ifdef MOZ_PHC
|
||||
mozilla::phc::MemoryUsage usage;
|
||||
ReplaceMalloc::PHCMemoryUsage(usage);
|
||||
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/heap-overhead/phc/metadata", KIND_NONHEAP, UNITS_BYTES,
|
||||
usage.mMetadataBytes,
|
||||
"Memory used by PHC to store stacks and other metadata for each allocation");
|
||||
MOZ_COLLECT_REPORT(
|
||||
"explicit/heap-overhead/phc/fragmentation", KIND_NONHEAP, UNITS_BYTES,
|
||||
usage.mFragmentationBytes,
|
||||
"The amount of memory lost due to rounding up allocations to the next page "
|
||||
"size. "
|
||||
"This is also known as 'internal fragmentation'. "
|
||||
"Note that all allocators have some internal fragmentation, there may still "
|
||||
"be some internal fragmentation without PHC.");
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user