mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 1167292 - Part 3: Add telemetry probes for node and edge counts when saving heap snapshots; r=ejpbruel
This commit is contained in:
parent
7f059162e3
commit
d285eb00b3
@ -7092,6 +7092,20 @@
|
||||
"n_buckets": "1000",
|
||||
"description": "The time (in milliseconds) that it took to read a heap snapshot in mozilla::devtools::ChromeUtils::ReadHeapSnapshot."
|
||||
},
|
||||
"DEVTOOLS_HEAP_SNAPSHOT_NODE_COUNT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "10000000",
|
||||
"n_buckets": "10000",
|
||||
"description": "The number of nodes serialized into a heap snapshot."
|
||||
},
|
||||
"DEVTOOLS_HEAP_SNAPSHOT_EDGE_COUNT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "linear",
|
||||
"high": "10000000",
|
||||
"n_buckets": "10000",
|
||||
"description": "The number of edges serialized into a heap snapshot."
|
||||
},
|
||||
"BROWSER_IS_USER_DEFAULT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
|
@ -461,6 +461,10 @@ class MOZ_STACK_CLASS HeapSnapshotHandler
|
||||
JS::ZoneSet* zones;
|
||||
|
||||
public:
|
||||
// For telemetry.
|
||||
uint32_t nodeCount;
|
||||
uint32_t edgeCount;
|
||||
|
||||
HeapSnapshotHandler(CoreDumpWriter& writer,
|
||||
JS::ZoneSet* zones)
|
||||
: writer(writer),
|
||||
@ -477,6 +481,8 @@ public:
|
||||
NodeData*,
|
||||
bool first)
|
||||
{
|
||||
edgeCount++;
|
||||
|
||||
// We're only interested in the first time we reach edge.referent, not in
|
||||
// every edge arriving at that node. "But, don't we want to serialize every
|
||||
// edge in the heap graph?" you ask. Don't worry! This edge is still
|
||||
@ -486,6 +492,8 @@ public:
|
||||
if (!first)
|
||||
return true;
|
||||
|
||||
nodeCount++;
|
||||
|
||||
const JS::ubi::Node& referent = edge.referent;
|
||||
|
||||
if (!zones)
|
||||
@ -517,7 +525,9 @@ WriteHeapGraph(JSContext* cx,
|
||||
CoreDumpWriter& writer,
|
||||
bool wantNames,
|
||||
JS::ZoneSet* zones,
|
||||
JS::AutoCheckCannotGC& noGC)
|
||||
JS::AutoCheckCannotGC& noGC,
|
||||
uint32_t& outNodeCount,
|
||||
uint32_t& outEdgeCount)
|
||||
{
|
||||
// Serialize the starting node to the core dump.
|
||||
|
||||
@ -534,8 +544,15 @@ WriteHeapGraph(JSContext* cx,
|
||||
return false;
|
||||
traversal.wantNames = wantNames;
|
||||
|
||||
return traversal.addStartVisited(node) &&
|
||||
traversal.traverse();
|
||||
bool ok = traversal.addStartVisited(node) &&
|
||||
traversal.traverse();
|
||||
|
||||
if (ok) {
|
||||
outNodeCount = handler.nodeCount;
|
||||
outEdgeCount = handler.edgeCount;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
} // namespace devtools
|
||||
@ -556,13 +573,8 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
|
||||
|
||||
bool wantNames = true;
|
||||
ZoneSet zones;
|
||||
Maybe<AutoCheckCannotGC> maybeNoGC;
|
||||
ubi::RootList rootList(cx, maybeNoGC, wantNames);
|
||||
if (!EstablishBoundaries(cx, rv, boundaries, rootList, zones))
|
||||
return;
|
||||
|
||||
MOZ_ASSERT(maybeNoGC.isSome());
|
||||
ubi::Node roots(&rootList);
|
||||
uint32_t nodeCount = 0;
|
||||
uint32_t edgeCount = 0;
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
rv = NS_NewLocalFile(filePath, false, getter_AddRefs(file));
|
||||
@ -581,25 +593,41 @@ ThreadSafeChromeUtils::SaveHeapSnapshot(GlobalObject& global,
|
||||
|
||||
StreamWriter writer(cx, gzipStream, wantNames);
|
||||
|
||||
// Serialize the initial heap snapshot metadata to the core dump.
|
||||
if (!writer.writeMetadata(PR_Now()) ||
|
||||
// Serialize the heap graph to the core dump, starting from our list of
|
||||
// roots.
|
||||
!WriteHeapGraph(cx,
|
||||
roots,
|
||||
writer,
|
||||
wantNames,
|
||||
zones.initialized() ? &zones : nullptr,
|
||||
maybeNoGC.ref()))
|
||||
{
|
||||
rv.Throw(zeroCopyStream.failed()
|
||||
? zeroCopyStream.result()
|
||||
: NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
Maybe<AutoCheckCannotGC> maybeNoGC;
|
||||
ubi::RootList rootList(cx, maybeNoGC, wantNames);
|
||||
if (!EstablishBoundaries(cx, rv, boundaries, rootList, zones))
|
||||
return;
|
||||
|
||||
MOZ_ASSERT(maybeNoGC.isSome());
|
||||
ubi::Node roots(&rootList);
|
||||
|
||||
// Serialize the initial heap snapshot metadata to the core dump.
|
||||
if (!writer.writeMetadata(PR_Now()) ||
|
||||
// Serialize the heap graph to the core dump, starting from our list of
|
||||
// roots.
|
||||
!WriteHeapGraph(cx,
|
||||
roots,
|
||||
writer,
|
||||
wantNames,
|
||||
zones.initialized() ? &zones : nullptr,
|
||||
maybeNoGC.ref(),
|
||||
nodeCount,
|
||||
edgeCount))
|
||||
{
|
||||
rv.Throw(zeroCopyStream.failed()
|
||||
? zeroCopyStream.result()
|
||||
: NS_ERROR_UNEXPECTED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Telemetry::AccumulateTimeDelta(Telemetry::DEVTOOLS_SAVE_HEAP_SNAPSHOT_MS,
|
||||
start);
|
||||
Telemetry::Accumulate(Telemetry::DEVTOOLS_HEAP_SNAPSHOT_NODE_COUNT,
|
||||
nodeCount);
|
||||
Telemetry::Accumulate(Telemetry::DEVTOOLS_HEAP_SNAPSHOT_EDGE_COUNT,
|
||||
edgeCount);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<HeapSnapshot>
|
||||
|
@ -162,7 +162,22 @@ WriteHeapGraph(JSContext* cx,
|
||||
CoreDumpWriter& writer,
|
||||
bool wantNames,
|
||||
JS::ZoneSet* zones,
|
||||
JS::AutoCheckCannotGC& noGC);
|
||||
JS::AutoCheckCannotGC& noGC,
|
||||
uint32_t& outNodeCount,
|
||||
uint32_t& outEdgeCount);
|
||||
inline bool
|
||||
WriteHeapGraph(JSContext* cx,
|
||||
const JS::ubi::Node& node,
|
||||
CoreDumpWriter& writer,
|
||||
bool wantNames,
|
||||
JS::ZoneSet* zones,
|
||||
JS::AutoCheckCannotGC& noGC)
|
||||
{
|
||||
uint32_t ignoreNodeCount;
|
||||
uint32_t ignoreEdgeCount;
|
||||
return WriteHeapGraph(cx, node, writer, wantNames, zones, noGC,
|
||||
ignoreNodeCount, ignoreEdgeCount);
|
||||
}
|
||||
|
||||
} // namespace devtools
|
||||
} // namespace mozilla
|
||||
|
Loading…
Reference in New Issue
Block a user