Skip to content

Commit 255c9eb

Browse files
sethbrenithDevtools-frontend LUCI CQ
authored andcommitted
Include extra native bytes in heap snapshot total size
V8 recently started reporting how much Oilpan memory is not represented in a heap snapshot. This change updates DevTools to include that extra memory when computing the total size, so that the total size reported for the snapshot can better match Blink's actual memory usage. Bug: 40734351 Change-Id: I89e176e164ac73779ef4ced9d52871a1056e0704 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6216979 Commit-Queue: Seth Brenith <[email protected]> Reviewed-by: Simon Zünd <[email protected]>
1 parent 296c5d4 commit 255c9eb

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ export abstract class HeapSnapshot {
764764
#aggregatesSortedFlags: {
765765
[x: string]: boolean,
766766
};
767-
#profile: Profile;
767+
profile: Profile;
768768
nodeTypeOffset!: number;
769769
nodeNameOffset!: number;
770770
nodeIdOffset!: number;
@@ -845,7 +845,7 @@ export abstract class HeapSnapshot {
845845
this.#aggregates = {};
846846

847847
this.#aggregatesSortedFlags = {};
848-
this.#profile = profile;
848+
this.profile = profile;
849849
this.#ignoredNodesInRetainersView = new Set();
850850
this.#ignoredEdgesInRetainersView = new Set();
851851
this.#edgeNamesThatAreNotWeakMaps = Platform.TypedArrayUtilities.createBitVector(this.strings.length);
@@ -939,7 +939,7 @@ export abstract class HeapSnapshot {
939939
this.buildLocationMap();
940940
this.#progress.updateStatus('Finished processing.');
941941

942-
if (this.#profile.snapshot.trace_function_count) {
942+
if (this.profile.snapshot.trace_function_count) {
943943
this.#progress.updateStatus('Building allocation statistics…');
944944
const nodes = this.nodes;
945945
const nodesLength = nodes.length;
@@ -961,7 +961,7 @@ export abstract class HeapSnapshot {
961961
stats.size += node.selfSize();
962962
stats.ids.push(node.id());
963963
}
964-
this.#allocationProfile = new AllocationProfile(this.#profile, liveObjects);
964+
this.#allocationProfile = new AllocationProfile(this.profile, liveObjects);
965965
this.#progress.updateStatus('done');
966966
}
967967
}
@@ -1045,7 +1045,7 @@ export abstract class HeapSnapshot {
10451045
}
10461046

10471047
get totalSize(): number {
1048-
return this.rootNode().retainedSize();
1048+
return this.rootNode().retainedSize() + (this.profile.snapshot.extra_native_bytes ?? 0);
10491049
}
10501050

10511051
private getDominatedIndex(nodeIndex: number): number {
@@ -2755,6 +2755,7 @@ export interface HeapSnapshotHeader {
27552755
edge_count: number;
27562756
trace_function_count: number;
27572757
root_index: number;
2758+
extra_native_bytes?: number;
27582759
/* eslint-enable @typescript-eslint/naming-convention */
27592760
}
27602761

@@ -3415,7 +3416,7 @@ export class JSHeapSnapshot extends HeapSnapshot {
34153416
const nodeSlicedStringType = this.nodeSlicedStringType;
34163417
const nodeHiddenType = this.nodeHiddenType;
34173418
const nodeStringType = this.nodeStringType;
3418-
let sizeNative = 0;
3419+
let sizeNative = this.profile.snapshot.extra_native_bytes ?? 0;
34193420
let sizeTypedArrays = 0;
34203421
let sizeCode = 0;
34213422
let sizeStrings = 0;

front_end/legacy_test_runner/heap_profiler_test_runner/heap_profiler_test_runner.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ HeapProfilerTestRunner.createHeapSnapshotMockFactories = function() {
233233
this.nodeFieldsCount = 7;
234234
this.nodeTypesMap = {};
235235
this.nodeTypesArray = [];
236+
this.extraNativeBytes = 0;
236237

237238
for (const nodeType in HeapProfilerTestRunner.HeapNode.Type) {
238239
this.nodeTypesMap[nodeType] = this.nodeTypesArray.length;
@@ -260,7 +261,8 @@ HeapProfilerTestRunner.createHeapSnapshotMockFactories = function() {
260261
node_types: [this.nodeTypesArray, 'string', 'number', 'number', 'number', 'number', 'number'],
261262
edge_fields: ['type', 'name_or_index', 'to_node'],
262263
edge_types: [this.edgeTypesArray, 'string_or_number', 'node']
263-
}
264+
},
265+
extra_native_bytes: this.extraNativeBytes
264266
},
265267

266268
nodes: [],

0 commit comments

Comments
 (0)