Bug 1441972 - Add probe for counting docgroups per tabgroup. r=nika, data-review=chutten

Add ACTIVE_DOCGROUPS_PER_TABGROUP and TOTAL_DOCGROUPS_PER_TABGROUP to
collect data on how many docgroups a tabgroup has whenever a top level
content document associated with that tabgroup would hide. This gives
a fairly accurate estimate of the number of docgroups a site
uses. TOTAL_* counts all docgroups while ACTIVE_* only count docgroups
with at least one document not in the bfcache.
This commit is contained in:
Andreas Farre 2018-05-30 05:48:00 +03:00
Родитель ceb0d57195
Коммит 4997325757
6 изменённых файлов: 68 добавлений и 0 удалений

Просмотреть файл

@ -184,5 +184,17 @@ DocGroup::MoveSignalSlotListTo(nsTArray<RefPtr<HTMLSlotElement>>& aDest)
mSignalSlotList.Clear();
}
bool
DocGroup::IsActive() const
{
for (nsIDocument* doc : mDocuments) {
if (doc->IsCurrentActiveDocument()) {
return true;
}
}
return false;
}
}
}

Просмотреть файл

@ -122,6 +122,9 @@ public:
// List of DocGroups that has non-empty signal slot list.
static AutoTArray<RefPtr<DocGroup>, 2>* sPendingDocGroups;
// Returns true if any of its documents are active but not in the bfcache.
bool IsActive() const;
private:
DocGroup(TabGroup* aTabGroup, const nsACString& aKey);
~DocGroup();

Просмотреть файл

@ -306,5 +306,22 @@ TabGroup::IsBackground() const
return mForegroundCount == 0;
}
uint32_t
TabGroup::Count(bool aActiveOnly) const
{
if (!aActiveOnly) {
return mDocGroups.Count();
}
uint32_t count = 0;
for (auto iter = mDocGroups.ConstIter(); !iter.Done(); iter.Next()) {
if (iter.Get()->mDocGroup->IsActive()) {
++count;
}
}
return count;
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -100,6 +100,10 @@ public:
return mDocGroups.Iter();
}
// Returns the size of the set of "similar-origin" DocGroups. To
// only consider DocGroups with at least one active document, call
// Count with 'aActiveOnly' = true
uint32_t Count(bool aActiveOnly = false) const;
// Returns the nsIDocShellTreeItem with the given name, searching each of the
// docShell trees which are within this TabGroup. It will pass itself as

Просмотреть файл

@ -8495,6 +8495,18 @@ static void ClearPendingFullscreenRequests(nsIDocument* aDoc);
void
nsIDocument::OnPageHide(bool aPersisted, EventTarget* aDispatchStartTarget)
{
if (mDocGroup && Telemetry::CanRecordExtended() &&
IsTopLevelContentDocument()) {
TabGroup* tabGroup = mDocGroup->GetTabGroup();
if (tabGroup) {
Telemetry::Accumulate(Telemetry::ACTIVE_DOCGROUPS_PER_TABGROUP,
tabGroup->Count(true /* aActiveOnly */));
Telemetry::Accumulate(Telemetry::TOTAL_DOCGROUPS_PER_TABGROUP,
tabGroup->Count());
}
}
// Send out notifications that our <link> elements are detached,
// but only if this is not a full unload.
Element* root = GetRootElement();

Просмотреть файл

@ -13784,5 +13784,25 @@
"n_buckets": 20,
"releaseChannelCollection": "opt-out",
"description": "Number of HTML editors whose inline table editing UI is actually used by users."
},
"ACTIVE_DOCGROUPS_PER_TABGROUP": {
"record_in_processes": ["content"],
"alert_emails": ["farre@mozilla.com"],
"bug_numbers": [1441972],
"expires_in_version": "67",
"kind": "exponential",
"high": 50,
"n_buckets": 20,
"description": "Number of active doc groups per tab group. Collected at the point when the top level document of the tab group is unloaded."
},
"TOTAL_DOCGROUPS_PER_TABGROUP": {
"record_in_processes": ["content"],
"alert_emails": ["farre@mozilla.com"],
"bug_numbers": [1441972],
"expires_in_version": "67",
"kind": "exponential",
"high": 50,
"n_buckets": 20,
"description": "Total number of doc groups per tab group, including docgroups fully in bfcache. Collected at the point when the top level document of the tab group is unloaded."
}
}