mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 04:27:37 +00:00
538706caba
Jemalloc 4 purges dirty pages regularly during free() when the ratio of dirty pages compared to active pages is higher than 1 << lg_dirty_mult. We set lg_dirty_mult in jemalloc_config to limit RSS usage, but it also has an impact on performance. So instead of enforcing a high ratio to force more pages being purged, we keep jemalloc's default ratio of 8, and force a regular purge of all dirty pages, after cycle collection. Keeping jemalloc's default ratio avoids cycle-collection-triggered purge to have to go through really all dirty pages when there are a lot, in which case the normal jemalloc purge during free() will already have kicked in. It also takes care of everything that doesn't run the cycle collector still having a level of purge, like plugins in the plugin-container. At the same time, since jemalloc_purge_freed_pages does nothing with jemalloc 4, repurpose the MEMORY_FREE_PURGED_PAGES_MS telemetry probe to track the time spent in this cycle-collector-triggered purge.
70 lines
2.3 KiB
C++
70 lines
2.3 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef nsCycleCollector_h__
|
|
#define nsCycleCollector_h__
|
|
|
|
class nsICycleCollectorListener;
|
|
class nsICycleCollectorLogSink;
|
|
class nsISupports;
|
|
template<class T> struct already_AddRefed;
|
|
|
|
#include "nsError.h"
|
|
#include "nsID.h"
|
|
|
|
#include "js/SliceBudget.h"
|
|
|
|
namespace mozilla {
|
|
class CycleCollectedJSRuntime;
|
|
} // namespace mozilla
|
|
|
|
bool nsCycleCollector_init();
|
|
|
|
void nsCycleCollector_startup();
|
|
|
|
typedef void (*CC_BeforeUnlinkCallback)(void);
|
|
void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB);
|
|
|
|
typedef void (*CC_ForgetSkippableCallback)(void);
|
|
void nsCycleCollector_setForgetSkippableCallback(CC_ForgetSkippableCallback aCB);
|
|
|
|
void nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes = false,
|
|
bool aAsyncSnowWhiteFreeing = false);
|
|
|
|
void nsCycleCollector_prepareForGarbageCollection();
|
|
|
|
// If an incremental cycle collection is in progress, finish it.
|
|
void nsCycleCollector_finishAnyCurrentCollection();
|
|
|
|
void nsCycleCollector_dispatchDeferredDeletion(bool aContinuation = false,
|
|
bool aPurge = false);
|
|
bool nsCycleCollector_doDeferredDeletion();
|
|
|
|
already_AddRefed<nsICycleCollectorLogSink> nsCycleCollector_createLogSink();
|
|
|
|
void nsCycleCollector_collect(nsICycleCollectorListener* aManualListener);
|
|
|
|
void nsCycleCollector_collectSlice(js::SliceBudget& budget,
|
|
bool aPreferShorterSlices = false);
|
|
|
|
uint32_t nsCycleCollector_suspectedCount();
|
|
void nsCycleCollector_shutdown();
|
|
|
|
// Helpers for interacting with JS
|
|
void nsCycleCollector_registerJSRuntime(mozilla::CycleCollectedJSRuntime* aRt);
|
|
void nsCycleCollector_forgetJSRuntime();
|
|
|
|
#define NS_CYCLE_COLLECTOR_LOGGER_CID \
|
|
{ 0x58be81b4, 0x39d2, 0x437c, \
|
|
{ 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } }
|
|
|
|
extern nsresult
|
|
nsCycleCollectorLoggerConstructor(nsISupports* aOuter,
|
|
const nsIID& aIID,
|
|
void** aInstancePtr);
|
|
|
|
#endif // nsCycleCollector_h__
|