Commit 5656d811 authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

Emit "function calls in detached window" use counters via UKM

This change adds use counters for counting V8 function calls in detached
windows. They aren't emitted the usual way, because the use counter
infrastructure doesn't work on detached windows. Instead they're plumbed
through instance counters to be emitted via UKM.

Bug: 1018156
Change-Id: I2c85604c9a96b9aec50896a74c089cf5eacfa61d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925839
Commit-Queue: Bartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721875}
parent b561054a
......@@ -86,6 +86,15 @@ const char* const kAllocatorDumpNameWhitelist[] = {
"blink_objects/Resource",
"blink_objects/RTCPeerConnection",
"blink_objects/ScriptPromise",
"blink_objects/V8CallInDetachedWindowByNavigation",
"blink_objects/V8CallInDetachedWindowByNavigationAfter10s",
"blink_objects/V8CallInDetachedWindowByNavigationAfter1min",
"blink_objects/V8CallInDetachedWindowByClosing",
"blink_objects/V8CallInDetachedWindowByClosingAfter10s",
"blink_objects/V8CallInDetachedWindowByClosingAfter1min",
"blink_objects/V8CallInDetachedWindowByOtherReason",
"blink_objects/V8CallInDetachedWindowByOtherReasonAfter10s",
"blink_objects/V8CallInDetachedWindowByOtherReasonAfter1min",
"blink_objects/V8PerContextData",
"blink_objects/WorkerGlobalScope",
"blink_objects/UACSSResource",
......
......@@ -93,6 +93,48 @@ const Metric kAllocatorDumpNamesForMetrics[] = {
!kLargeMetric, MemoryAllocatorDump::kNameObjectCount,
EmitTo::kCountsInUkmOnly,
&Memory_Experimental::SetNumberOfDetachedScriptStates},
{"blink_objects/V8CallInDetachedWindowByNavigation",
"NumberOfCallsInDetachedWindowByNavigation", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::SetNumberOfCallsInDetachedWindowByNavigation},
{"blink_objects/V8CallInDetachedWindowByNavigationAfter10s",
"NumberOfCallsInDetachedWindowByNavigationAfter10s", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::
SetNumberOfCallsInDetachedWindowByNavigation_After10sSinceDetaching},
{"blink_objects/V8CallInDetachedWindowByNavigationAfter1min",
"NumberOfCallsInDetachedWindowByNavigationAfter1min", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::
SetNumberOfCallsInDetachedWindowByNavigation_After1minSinceDetaching},
{"blink_objects/V8CallInDetachedWindowByClosing",
"NumberOfCallsInDetachedWindowByClosing", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::SetNumberOfCallsInDetachedWindowByClosing},
{"blink_objects/V8CallInDetachedWindowByClosingAfter10s",
"NumberOfCallsInDetachedWindowByClosingAfter10s", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::
SetNumberOfCallsInDetachedWindowByClosing_After10sSinceDetaching},
{"blink_objects/V8CallInDetachedWindowByClosingAfter1min",
"NumberOfCallsInDetachedWindowByClosingAfter1min", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::
SetNumberOfCallsInDetachedWindowByClosing_After1minSinceDetaching},
{"blink_objects/V8CallInDetachedWindowByOtherReason",
"NumberOfCallsInDetachedWindowByOtherReason", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::SetNumberOfCallsInDetachedWindowByOtherReason},
{"blink_objects/V8CallInDetachedWindowByOtherReasonAfter10s",
"NumberOfCallsInDetachedWindowByOtherReasonAfter10s", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::
SetNumberOfCallsInDetachedWindowByOtherReason_After10sSinceDetaching},
{"blink_objects/V8CallInDetachedWindowByOtherReasonAfter1min",
"NumberOfCallsInDetachedWindowByOtherReasonAfter1min", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::
SetNumberOfCallsInDetachedWindowByOtherReason_After1minSinceDetaching},
{"blink_objects/Frame", "NumberOfFrames", !kLargeMetric,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::SetNumberOfFrames},
......@@ -753,10 +795,9 @@ void ProcessMemoryMetricsEmitter::CollateResults() {
}
}
// If there is more than one frame being hosted in a renderer, don't
// emit any per-renderer URLs. This is not ideal, but UKM does not
// support multiple-URLs per entry, and we must have one entry per
// process.
// If there is more than one tab being hosted in a renderer, don't
// emit certain data. This is not ideal, but UKM does not support
// multiple-URLs per entry, and we must have one entry per process.
if (process_info.page_infos.size() == 1) {
single_page_info = &process_info.page_infos[0];
}
......
......@@ -2492,6 +2492,15 @@ enum WebFeature {
kInputElementValueAsDateSetter = 3111,
kHTMLMetaElementReferrerPolicy = 3112,
kNonWebbyMixedContent = 3113,
kV8CallInDetachedWindowByNavigation = 3114,
kV8CallInDetachedWindowByNavigationAfter10s = 3115,
kV8CallInDetachedWindowByNavigationAfter1min = 3116,
kV8CallInDetachedWindowByClosing = 3117,
kV8CallInDetachedWindowByClosingAfter10s = 3118,
kV8CallInDetachedWindowByClosingAfter1min = 3119,
kV8CallInDetachedWindowByOtherReason = 3120,
kV8CallInDetachedWindowByOtherReasonAfter10s = 3121,
kV8CallInDetachedWindowByOtherReasonAfter1min = 3122,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
......
......@@ -8,6 +8,7 @@
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/instrumentation/instance_counters.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
namespace blink {
......@@ -240,6 +241,51 @@ void UseCounterCallback(v8::Isolate* isolate,
case v8::Isolate::kRegExpReplaceCalledOnSlowRegExp:
blink_feature = WebFeature::kV8RegExpReplaceCalledOnSlowRegExp;
break;
// The following 9 counters differ from the rest, because they're reported
// via UKM using the instance counter mechanism. Using the typical use
// counter infrastructure won't work, because it doesn't work on detached
// windows.
// TODO(bartekn,chromium:1018156): Remove once not needed.
case v8::Isolate::kCallInDetachedWindowByNavigation:
InstanceCounters::IncrementCounter(
InstanceCounters::kV8CallInDetachedWindowByNavigationCounter);
return;
case v8::Isolate::kCallInDetachedWindowByNavigationAfter10s:
InstanceCounters::IncrementCounter(
InstanceCounters::kV8CallInDetachedWindowByNavigationAfter10sCounter);
return;
case v8::Isolate::kCallInDetachedWindowByNavigationAfter1min:
InstanceCounters::IncrementCounter(
InstanceCounters::
kV8CallInDetachedWindowByNavigationAfter1minCounter);
return;
case v8::Isolate::kCallInDetachedWindowByClosing:
InstanceCounters::IncrementCounter(
InstanceCounters::kV8CallInDetachedWindowByClosingCounter);
return;
case v8::Isolate::kCallInDetachedWindowByClosingAfter10s:
InstanceCounters::IncrementCounter(
InstanceCounters::kV8CallInDetachedWindowByClosingAfter10sCounter);
return;
case v8::Isolate::kCallInDetachedWindowByClosingAfter1min:
InstanceCounters::IncrementCounter(
InstanceCounters::kV8CallInDetachedWindowByClosingAfter1minCounter);
return;
case v8::Isolate::kCallInDetachedWindowByOtherReason:
InstanceCounters::IncrementCounter(
InstanceCounters::kV8CallInDetachedWindowByOtherReasonCounter);
return;
case v8::Isolate::kCallInDetachedWindowByOtherReasonAfter10s:
InstanceCounters::IncrementCounter(
InstanceCounters::
kV8CallInDetachedWindowByOtherReasonAfter10sCounter);
return;
case v8::Isolate::kCallInDetachedWindowByOtherReasonAfter1min:
InstanceCounters::IncrementCounter(
InstanceCounters::
kV8CallInDetachedWindowByOtherReasonAfter1minCounter);
return;
// End of special case.
default:
// This can happen if V8 has added counters that this version of Blink
// does not know about. It's harmless.
......
......@@ -38,24 +38,33 @@
namespace blink {
#define INSTANCE_COUNTERS_LIST(V) \
V(AudioHandler) \
V(Document) \
V(Frame) \
V(JSEventListener) \
V(LayoutObject) \
V(MediaKeySession) \
V(MediaKeys) \
V(Node) \
V(Resource) \
V(ContextLifecycleStateObserver) \
V(V8PerContextData) \
V(WorkerGlobalScope) \
V(UACSSResource) \
V(RTCPeerConnection) \
V(ResourceFetcher) \
V(AdSubframe) \
V(DetachedScriptState)
#define INSTANCE_COUNTERS_LIST(V) \
V(AudioHandler) \
V(Document) \
V(Frame) \
V(JSEventListener) \
V(LayoutObject) \
V(MediaKeySession) \
V(MediaKeys) \
V(Node) \
V(Resource) \
V(ContextLifecycleStateObserver) \
V(V8PerContextData) \
V(WorkerGlobalScope) \
V(UACSSResource) \
V(RTCPeerConnection) \
V(ResourceFetcher) \
V(AdSubframe) \
V(DetachedScriptState) \
V(V8CallInDetachedWindowByNavigation) \
V(V8CallInDetachedWindowByNavigationAfter10s) \
V(V8CallInDetachedWindowByNavigationAfter1min) \
V(V8CallInDetachedWindowByClosing) \
V(V8CallInDetachedWindowByClosingAfter10s) \
V(V8CallInDetachedWindowByClosingAfter1min) \
V(V8CallInDetachedWindowByOtherReason) \
V(V8CallInDetachedWindowByOtherReasonAfter10s) \
V(V8CallInDetachedWindowByOtherReasonAfter1min)
// Atomic counters of the number of instances of objects that exist.
//
......
......@@ -31,6 +31,15 @@ TaskOtherDuration
ThreadTime
Timestamp
UACSSResources
V8CallInDetachedWindowByClosingAfter10s
V8CallInDetachedWindowByClosingAfter1mins
V8CallInDetachedWindowByClosings
V8CallInDetachedWindowByNavigationAfter10s
V8CallInDetachedWindowByNavigationAfter1mins
V8CallInDetachedWindowByNavigations
V8CallInDetachedWindowByOtherReasonAfter10s
V8CallInDetachedWindowByOtherReasonAfter1mins
V8CallInDetachedWindowByOtherReasons
V8CompileDuration
V8PerContextDatas
WorkerGlobalScopes
......
......@@ -18,6 +18,15 @@ title: test1
ResourceFetchers
AdSubframes
DetachedScriptStates
V8CallInDetachedWindowByNavigations
V8CallInDetachedWindowByNavigationAfter10s
V8CallInDetachedWindowByNavigationAfter1mins
V8CallInDetachedWindowByClosings
V8CallInDetachedWindowByClosingAfter10s
V8CallInDetachedWindowByClosingAfter1mins
V8CallInDetachedWindowByOtherReasons
V8CallInDetachedWindowByOtherReasonAfter10s
V8CallInDetachedWindowByOtherReasonAfter1mins
LayoutCount
RecalcStyleCount
LayoutDuration
......@@ -51,6 +60,15 @@ title: test1
ResourceFetchers
AdSubframes
DetachedScriptStates
V8CallInDetachedWindowByNavigations
V8CallInDetachedWindowByNavigationAfter10s
V8CallInDetachedWindowByNavigationAfter1mins
V8CallInDetachedWindowByClosings
V8CallInDetachedWindowByClosingAfter10s
V8CallInDetachedWindowByClosingAfter1mins
V8CallInDetachedWindowByOtherReasons
V8CallInDetachedWindowByOtherReasonAfter10s
V8CallInDetachedWindowByOtherReasonAfter1mins
LayoutCount
RecalcStyleCount
LayoutDuration
......@@ -84,6 +102,15 @@ title:
ResourceFetchers
AdSubframes
DetachedScriptStates
V8CallInDetachedWindowByNavigations
V8CallInDetachedWindowByNavigationAfter10s
V8CallInDetachedWindowByNavigationAfter1mins
V8CallInDetachedWindowByClosings
V8CallInDetachedWindowByClosingAfter10s
V8CallInDetachedWindowByClosingAfter1mins
V8CallInDetachedWindowByOtherReasons
V8CallInDetachedWindowByOtherReasonAfter10s
V8CallInDetachedWindowByOtherReasonAfter1mins
LayoutCount
RecalcStyleCount
LayoutDuration
......
......@@ -25650,6 +25650,15 @@ Called by update_net_error_codes.py.-->
<int value="3111" label="InputElementValueAsDateSetter"/>
<int value="3112" label="HTMLMetaElementReferrerPolicy"/>
<int value="3113" label="NonWebbyMixedContent"/>
<int value="3114" label="V8CallInDetachedWindowByNavigation"/>
<int value="3115" label="V8CallInDetachedWindowByNavigationAfter10s"/>
<int value="3116" label="V8CallInDetachedWindowByNavigationAfter1min"/>
<int value="3117" label="V8CallInDetachedWindowByClosing"/>
<int value="3118" label="V8CallInDetachedWindowByClosingAfter10s"/>
<int value="3119" label="V8CallInDetachedWindowByClosingAfter1min"/>
<int value="3120" label="V8CallInDetachedWindowByOtherReason"/>
<int value="3121" label="V8CallInDetachedWindowByOtherReasonAfter10s"/>
<int value="3122" label="V8CallInDetachedWindowByOtherReasonAfter1min"/>
</enum>
<enum name="FeaturePolicyAllowlistType">
......@@ -4822,6 +4822,61 @@ be describing additional metrics about the same event.
The number of ad subframes that the associated renderer owns.
</summary>
</metric>
<metric name="NumberOfCallsInDetachedWindowByClosing">
<summary>
The number of function calls in a window detached by closing/removal.
</summary>
</metric>
<metric name="NumberOfCallsInDetachedWindowByClosing_After10sSinceDetaching">
<summary>
The number of function calls in a window detached by closing/removal, that
happened at least 10 seconds after detaching.
</summary>
</metric>
<metric name="NumberOfCallsInDetachedWindowByClosing_After1minSinceDetaching">
<summary>
The number of function calls in a window detached by closing/removal, that
happened at least 1 minute after detaching.
</summary>
</metric>
<metric name="NumberOfCallsInDetachedWindowByNavigation">
<summary>
The number of function calls in a window detached by navigating away.
</summary>
</metric>
<metric
name="NumberOfCallsInDetachedWindowByNavigation_After10sSinceDetaching">
<summary>
The number of function calls in a window detached by navigating away, that
happened at least 10 seconds after detaching.
</summary>
</metric>
<metric
name="NumberOfCallsInDetachedWindowByNavigation_After1minSinceDetaching">
<summary>
The number of function calls in a window detached by navigating away, that
happened at least 1 minute after detaching.
</summary>
</metric>
<metric name="NumberOfCallsInDetachedWindowByOtherReason">
<summary>
The number of function calls in a window detached by another reason.
</summary>
</metric>
<metric
name="NumberOfCallsInDetachedWindowByOtherReason_After10sSinceDetaching">
<summary>
The number of function calls in a window detached by another reason, that
happened at least 10 seconds after detaching.
</summary>
</metric>
<metric
name="NumberOfCallsInDetachedWindowByOtherReason_After1minSinceDetaching">
<summary>
The number of function calls in a window detached by another reason, that
happened at least 1 minute after detaching.
</summary>
</metric>
<metric name="NumberOfDetachedScriptStates">
<summary>
The number of detached ScriptState that the associated renderer owns.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment