RESOLVED FIXED 230957
[JSC] Add objectTypeCounts to JSGetMemoryUsageStatistics
https://bugs.webkit.org/show_bug.cgi?id=230957
Summary [JSC] Add objectTypeCounts to JSGetMemoryUsageStatistics
Basuke Suzuki
Reported 2021-09-29 08:54:35 PDT
It is very useful to have the numbers of each object types in the JS statistics.
Attachments
PATCH (4.85 KB, patch)
2021-09-29 12:11 PDT, Basuke Suzuki
ysuzuki: review+
PATCH (4.84 KB, patch)
2021-09-29 15:39 PDT, Basuke Suzuki
no flags
Basuke Suzuki
Comment 1 2021-09-29 12:11:35 PDT
Basuke Suzuki
Comment 2 2021-09-29 12:14:26 PDT
Added memoryUsageStatistics() to jsc. Input: function dump(values, indent = '') { for (const key in values) { const value = values[key]; if (typeof value === 'object') { print(`${indent}${key}:`); dump(value, indent + ' '); } else print(`${indent}${key}: ${value}`); } } dump(memoryUsageStatistics()); Output: heapSize: 0 heapCapacity: 344064 extraMemorySize: 0 objectCount: 0 protectedObjectCount: 44 protectedGlobalObjectCount: 0 objectTypeCounts: JSProxy: 1 Promise: 1 Callee: 2 Atomics: 1 ...
Yusuke Suzuki
Comment 3 2021-09-29 14:48:47 PDT
Comment on attachment 439639 [details] PATCH I think this is fine. r=me
Ross Kirsling
Comment 4 2021-09-29 14:56:53 PDT
Comment on attachment 439639 [details] PATCH View in context: https://bugs.webkit.org/attachment.cgi?id=439639&action=review > Source/JavaScriptCore/API/JSBase.cpp:208 > + JSObject* objectTypeCounts = constructEmptyObject(globalObject); I think you could do `constructEmptyObject(vm, globalObject->nullPrototypeObjectStructure())` since this object is just holding key-value pairs and doesn't need access to the Object prototype. > Source/JavaScriptCore/API/JSBasePrivate.h:74 > + objectTypeCounts: object which has kind as key and its number as value for each GC objects I think something like "object with HeapCell kinds as keys and their current counts as values" would be clearer.
Basuke Suzuki
Comment 5 2021-09-29 15:39:41 PDT
Basuke Suzuki
Comment 6 2021-09-29 15:41:01 PDT
Thanks Ross.
EWS
Comment 7 2021-09-29 17:19:15 PDT
Committed r283286 (242313@main): <https://commits.webkit.org/242313@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 439672 [details].
Radar WebKit Bug Importer
Comment 8 2021-09-29 17:20:27 PDT
Note You need to log in before you can comment on or make changes to this bug.