commit 6e08dc78bcde3dd851e1de0c7a0fa8f7c1bd3918
parent d8fb700cf5037e179dda09b2ba6e9941b5c2bcff
Author: unknown <daparks@mozilla.com>
Date: Mon, 8 Dec 2025 18:56:06 +0000
Bug 2004126: Maintain min-size for CCGraph::mPtrInfoMap r=mccr8
The approved patch in bug 1477627 was not the one that landed. The landed
code fails to maintain the min-size of an internal GC pointer map (16K)
and, after the first GC, reduces it to the min (4... as in 4, not 4K). This
causes the GC to constantly do rehashes, which constitute over 20% of time
taken by GC in a profile with a very long (10 second) GC.
The patch in bug 1477627 also used HashSet::initialized in CCGraph::IsEmpty,
but that seems wrong and no longer exists anyway.
Differential Revision: https://phabricator.services.mozilla.com/D275109
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp
@@ -827,12 +827,16 @@ struct CCGraph {
static const uint32_t kInitialMapLength = 16384;
public:
- CCGraph()
- : mRootCount(0), mPtrInfoMap(kInitialMapLength), mOutOfMemory(false) {}
+ CCGraph() : mRootCount(0), mOutOfMemory(false) {}
~CCGraph() = default;
- void Init() { MOZ_ASSERT(IsEmpty(), "Failed to call CCGraph::Clear"); }
+ void Init() {
+ MOZ_ASSERT(IsEmpty(), "Failed to call CCGraph::Clear");
+ if (!mPtrInfoMap.reserve(kInitialMapLength)) {
+ MOZ_CRASH("OOM");
+ }
+ }
void Clear() {
mNodes.Clear();