From 6163733cf09d81a16195409e6c8c00d5f99d89da Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Thu, 13 Jun 2024 17:01:50 +0200 Subject: [PATCH] Add an option to profile AppImage (#9998) * Add an option to profile AppImage Add `-debug.profile` on startup to turn on the profiler on a local machine and dump data to `profiling.npss` file. Previously not possible in a standalone setup. Useful for #9789. * fix linter * fix linter warning * more linting * lint --- app/gui2/src/composables/syncLocalStorage.ts | 1 - app/ide-desktop/lib/client/src/config.ts | 13 +++++++++++++ app/ide-desktop/lib/client/src/index.ts | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/gui2/src/composables/syncLocalStorage.ts b/app/gui2/src/composables/syncLocalStorage.ts index 9d86e509e2ce..2f228e6eb1ad 100644 --- a/app/gui2/src/composables/syncLocalStorage.ts +++ b/app/gui2/src/composables/syncLocalStorage.ts @@ -2,7 +2,6 @@ import { useAbortScope } from '@/util/net' import { debouncedWatch, useLocalStorage } from '@vueuse/core' import { encoding } from 'lib0' import { xxHash128 } from 'shared/ast/ffi' -import { assert } from 'shared/util/assert' import { AbortScope } from 'shared/util/net' import { computed, getCurrentInstance, ref, watch, withCtx } from 'vue' diff --git a/app/ide-desktop/lib/client/src/config.ts b/app/ide-desktop/lib/client/src/config.ts index 1905d8949160..f01c603e7767 100644 --- a/app/ide-desktop/lib/client/src/config.ts +++ b/app/ide-desktop/lib/client/src/config.ts @@ -17,6 +17,7 @@ export const HELP_EXTENDED_OPTION_NAME = naming.camelToKebabCase(HELP_EXTENDED_N const DEFAULT_WIDTH = 1380 const DEFAULT_HEIGHT = 900 const DEFAULT_PORT = 8080 +const DEFAULT_PROFILING_TIME = 120 // ================== // === WindowSize === @@ -313,6 +314,18 @@ export const CONFIG = contentConfig.OPTIONS.merge( value: false, description: 'Run the application in development mode.', }), + profile: new contentConfig.Option({ + passToWebApplication: false, + value: false, + description: + 'Start backend profiler on startup and log data to a profiling.npss file', + }), + profileTime: new contentConfig.Option({ + passToWebApplication: false, + value: DEFAULT_PROFILING_TIME, + description: + 'Time since backend startup for which profiling data will be collected, if enabled', + }), }, }), chrome: new contentConfig.Group({ diff --git a/app/ide-desktop/lib/client/src/index.ts b/app/ide-desktop/lib/client/src/index.ts index 6b8ccce7600f..8e1ea7ad24c4 100644 --- a/app/ide-desktop/lib/client/src/index.ts +++ b/app/ide-desktop/lib/client/src/index.ts @@ -268,7 +268,14 @@ class App { }) const projectManagerUrl = `ws://${this.projectManagerHost}:${this.projectManagerPort}` this.args.groups.engine.options.projectManagerUrl.value = projectManagerUrl - const backendOpts = this.args.groups.debug.options.verbose.value ? ['-vv'] : [] + const backendVerboseOpts = this.args.groups.debug.options.verbose.value ? ['-vv'] : [] + const backendProfileTime = this.args.groups.debug.options.profileTime.value + ? ['--profiling-time', String(this.args.groups.debug.options.profileTime.value)] + : ['--profiling-time', '120'] + const backendProfileOpts = this.args.groups.debug.options.profile.value + ? ['--profiling-path', 'profiling.npss', ...backendProfileTime] + : [] + const backendOpts = [...backendVerboseOpts, ...backendProfileOpts] const backendEnv = Object.assign({}, process.env, { // These are environment variables, and MUST be in CONSTANT_CASE. // eslint-disable-next-line @typescript-eslint/naming-convention