diff --git a/src/node-tools/profiler-edit.ts b/src/node-tools/profiler-edit.ts index 961df029b3..a934bc0e99 100644 --- a/src/node-tools/profiler-edit.ts +++ b/src/node-tools/profiler-edit.ts @@ -5,6 +5,7 @@ import fs from 'fs'; import minimist from 'minimist'; import { unserializeProfileOfArbitraryFormat } from 'firefox-profiler/profile-logic/process-profile'; +import { computeCompactedProfile } from 'firefox-profiler/profile-logic/profile-compacting'; import { GOOGLE_STORAGE_BUCKET } from 'firefox-profiler/app-logic/constants'; import { compress } from 'firefox-profiler/utils/gz'; import { SymbolStore } from 'firefox-profiler/profile-logic/symbol-store'; @@ -143,11 +144,16 @@ export async function run(options: CliOptions) { profile.meta.symbolicated = true; } + const { profile: compactedProfile } = computeCompactedProfile(profile); + console.log(`Saving profile to ${options.output}`); if (options.output.endsWith('.gz')) { - fs.writeFileSync(options.output, await compress(JSON.stringify(profile))); + fs.writeFileSync( + options.output, + await compress(JSON.stringify(compactedProfile)) + ); } else { - fs.writeFileSync(options.output, JSON.stringify(profile)); + fs.writeFileSync(options.output, JSON.stringify(compactedProfile)); } console.log('Finished.'); } diff --git a/src/test/integration/profiler-edit/__snapshots__/profiler-edit.test.ts.snap b/src/test/integration/profiler-edit/__snapshots__/profiler-edit.test.ts.snap index 28da043c8d..71147b11fc 100644 --- a/src/test/integration/profiler-edit/__snapshots__/profiler-edit.test.ts.snap +++ b/src/test/integration/profiler-edit/__snapshots__/profiler-edit.test.ts.snap @@ -270,9 +270,9 @@ Object { 9, 6, 4, + 10, 11, 12, - 14, 4, 5, 6, @@ -518,8 +518,6 @@ Object { null, null, null, - null, - null, ], "isJS": Array [ false, @@ -535,10 +533,8 @@ Object { false, false, false, - false, - false, ], - "length": 15, + "length": 13, "lineNumber": Array [ null, null, @@ -553,25 +549,21 @@ Object { null, null, null, - null, - null, ], "name": Array [ - 21, - 22, - 25, - 29, - 26, - 23, - 24, - 31, - 32, - 30, + 6, + 7, + 10, + 14, + 11, + 8, + 9, + 16, + 17, 15, - 27, - 28, + 12, + 13, 18, - 33, ], "relevantForJS": Array [ false, @@ -587,8 +579,6 @@ Object { false, false, false, - false, - false, ], "resource": Array [ 0, @@ -601,8 +591,6 @@ Object { 4, 4, 3, - 1, - 2, 2, 2, 5, @@ -621,8 +609,6 @@ Object { null, null, null, - null, - null, ], }, "nativeSymbols": Object { @@ -673,19 +659,19 @@ Object { 5, ], "name": Array [ - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, ], }, "resourceTable": Object { @@ -707,12 +693,12 @@ Object { 5, ], "name": Array [ + 0, + 1, + 2, + 3, 4, 5, - 6, - 7, - 14, - 20, ], "type": Array [ 1, @@ -915,26 +901,11 @@ Object { ], }, "stringArray": Array [ - "0x6153", - "0x3ec3", - "0x948b", - "0x2bac", "dyld", "a.out", "libsystem_pthread.dylib", "libsystem_kernel.dylib", - "0x6f93", - "0x3db3", - "0x3d33", - "0xd47f", - "0xd567", - "0x43e8", "libsystem_c.dylib", - "0x3d67", - "0x6f9f", - "0x769f", - "0x4983", - "0x3f3c", "libsystem_platform.dylib", "start", "main", @@ -1598,9 +1569,9 @@ Object { 9, 6, 4, + 10, 11, 12, - 14, 4, 5, 6, @@ -1846,8 +1817,6 @@ Object { null, null, null, - null, - null, ], "isJS": Array [ false, @@ -1863,10 +1832,8 @@ Object { false, false, false, - false, - false, ], - "length": 15, + "length": 13, "lineNumber": Array [ null, null, @@ -1881,25 +1848,21 @@ Object { null, null, null, - null, - null, ], "name": Array [ - 21, - 22, - 25, - 29, - 26, - 23, - 24, - 31, - 32, - 30, + 6, + 7, + 10, + 14, + 11, + 8, + 9, + 16, + 17, 15, - 27, - 28, + 12, + 13, 18, - 33, ], "relevantForJS": Array [ false, @@ -1915,8 +1878,6 @@ Object { false, false, false, - false, - false, ], "resource": Array [ 0, @@ -1929,8 +1890,6 @@ Object { 4, 4, 3, - 1, - 2, 2, 2, 5, @@ -1949,8 +1908,6 @@ Object { null, null, null, - null, - null, ], }, "nativeSymbols": Object { @@ -2001,19 +1958,19 @@ Object { 5, ], "name": Array [ - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, ], }, "resourceTable": Object { @@ -2035,12 +1992,12 @@ Object { 5, ], "name": Array [ + 0, + 1, + 2, + 3, 4, 5, - 6, - 7, - 14, - 20, ], "type": Array [ 1, @@ -2243,26 +2200,11 @@ Object { ], }, "stringArray": Array [ - "0x6153", - "0x3ec3", - "0x948b", - "0x2bac", "dyld", "a.out", "libsystem_pthread.dylib", "libsystem_kernel.dylib", - "0x6f93", - "0x3db3", - "0x3d33", - "0xd47f", - "0xd567", - "0x43e8", "libsystem_c.dylib", - "0x3d67", - "0x6f9f", - "0x769f", - "0x4983", - "0x3f3c", "libsystem_platform.dylib", "start", "main", @@ -2926,9 +2868,9 @@ Object { 9, 6, 4, + 10, 11, 12, - 14, 4, 5, 6, @@ -3174,8 +3116,6 @@ Object { null, null, null, - null, - null, ], "isJS": Array [ false, @@ -3191,10 +3131,8 @@ Object { false, false, false, - false, - false, ], - "length": 15, + "length": 13, "lineNumber": Array [ null, null, @@ -3209,25 +3147,21 @@ Object { null, null, null, - null, - null, ], "name": Array [ - 21, - 22, - 25, - 29, - 26, - 23, - 24, - 31, - 32, - 30, + 6, + 7, + 10, + 14, + 11, + 8, + 9, + 16, + 17, 15, - 27, - 28, + 12, + 13, 18, - 33, ], "relevantForJS": Array [ false, @@ -3243,8 +3177,6 @@ Object { false, false, false, - false, - false, ], "resource": Array [ 0, @@ -3257,8 +3189,6 @@ Object { 4, 4, 3, - 1, - 2, 2, 2, 5, @@ -3277,8 +3207,6 @@ Object { null, null, null, - null, - null, ], }, "nativeSymbols": Object { @@ -3329,19 +3257,19 @@ Object { 5, ], "name": Array [ - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, ], }, "resourceTable": Object { @@ -3363,12 +3291,12 @@ Object { 5, ], "name": Array [ + 0, + 1, + 2, + 3, 4, 5, - 6, - 7, - 14, - 20, ], "type": Array [ 1, @@ -3571,26 +3499,11 @@ Object { ], }, "stringArray": Array [ - "0x6153", - "0x3ec3", - "0x948b", - "0x2bac", "dyld", "a.out", "libsystem_pthread.dylib", "libsystem_kernel.dylib", - "0x6f93", - "0x3db3", - "0x3d33", - "0xd47f", - "0xd567", - "0x43e8", "libsystem_c.dylib", - "0x3d67", - "0x6f9f", - "0x769f", - "0x4983", - "0x3f3c", "libsystem_platform.dylib", "start", "main", @@ -4254,9 +4167,9 @@ Object { 9, 6, 4, + 10, 11, 12, - 14, 4, 5, 6, @@ -4502,8 +4415,6 @@ Object { null, null, null, - null, - null, ], "isJS": Array [ false, @@ -4519,10 +4430,8 @@ Object { false, false, false, - false, - false, ], - "length": 15, + "length": 13, "lineNumber": Array [ null, null, @@ -4537,25 +4446,21 @@ Object { null, null, null, - null, - null, ], "name": Array [ - 21, - 22, - 25, - 29, - 26, - 23, - 24, - 31, - 32, - 30, + 6, + 7, + 10, + 14, + 11, + 8, + 9, + 16, + 17, 15, - 27, - 28, + 12, + 13, 18, - 33, ], "relevantForJS": Array [ false, @@ -4571,8 +4476,6 @@ Object { false, false, false, - false, - false, ], "resource": Array [ 0, @@ -4585,8 +4488,6 @@ Object { 4, 4, 3, - 1, - 2, 2, 2, 5, @@ -4605,8 +4506,6 @@ Object { null, null, null, - null, - null, ], }, "nativeSymbols": Object { @@ -4657,19 +4556,19 @@ Object { 5, ], "name": Array [ - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, ], }, "resourceTable": Object { @@ -4691,12 +4590,12 @@ Object { 5, ], "name": Array [ + 0, + 1, + 2, + 3, 4, 5, - 6, - 7, - 14, - 20, ], "type": Array [ 1, @@ -4899,26 +4798,11 @@ Object { ], }, "stringArray": Array [ - "0x6153", - "0x3ec3", - "0x948b", - "0x2bac", "dyld", "a.out", "libsystem_pthread.dylib", "libsystem_kernel.dylib", - "0x6f93", - "0x3db3", - "0x3d33", - "0xd47f", - "0xd567", - "0x43e8", "libsystem_c.dylib", - "0x3d67", - "0x6f9f", - "0x769f", - "0x4983", - "0x3f3c", "libsystem_platform.dylib", "start", "main",