From 4f048a9907a6ded623e85688e50aa60829bebac2 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Sun, 16 Mar 2025 22:15:52 -0700 Subject: [PATCH] AIX: profiler is inactive by default on both Client and Server To turn it on, either|or: - server side: aix.router.ts: DEBUG_LOG_PROFILER_ON_SERVER=true - client side: DEV BUILD + "debug mode" + DEBUG_LOG_PROFILER_ON_CLIENT=true to show on the console --- src/modules/aix/client/ContentReassembler.ts | 11 ++++++++--- src/modules/aix/server/api/aix.router.ts | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/modules/aix/client/ContentReassembler.ts b/src/modules/aix/client/ContentReassembler.ts index fc454d060..1fee552bf 100644 --- a/src/modules/aix/client/ContentReassembler.ts +++ b/src/modules/aix/client/ContentReassembler.ts @@ -21,6 +21,7 @@ const GENERATED_IMAGES_CONVERT_TO_COMPRESSED = true; // converts PNG to WebP or const GENERATED_IMAGES_COMPRESSION_QUALITY = 0.98; const ELLIPSIZE_DEV_ISSUE_MESSAGES = 4096; const MERGE_ISSUES_INTO_TEXT_PART_IF_OPEN = true; +const DEBUG_LOG_PROFILER_ON_CLIENT = false; // print Profiling particles when they come in, otherwise ignore them /** @@ -242,9 +243,13 @@ export class ContentReassembler { aixClientDebugger_setRequest(this.debuggerFrameId, op.dispatchRequest); break; case '_debugProfiler': - // only show this to developers in the console - console.warn('[AIX] chatGenerate profiler measurements:'); - console.table(op.measurements); + // Profiling particles will come in if the app is in "Debug Mode" + it's a Development build! + // Additionally to show them on the console (rather than just in the debugger) set the + // constant to `true`. + if (DEBUG_LOG_PROFILER_ON_CLIENT) { + console.warn('[AIX] chatGenerate profiler measurements:'); + console.table(op.measurements); + } break; case 'end': this.onCGEnd(op); diff --git a/src/modules/aix/server/api/aix.router.ts b/src/modules/aix/server/api/aix.router.ts index 15b0b7007..6bc9cdd6c 100644 --- a/src/modules/aix/server/api/aix.router.ts +++ b/src/modules/aix/server/api/aix.router.ts @@ -13,7 +13,7 @@ import { heartbeatsWhileAwaiting } from '../dispatch/heartbeatsWhileAwaiting'; // configuration -const DEBUG_LOG_PROFILER = false; // capture and log performance (server-side flag, it can also tbe set by the client to return the profiling data) +const DEBUG_LOG_PROFILER_ON_SERVER = false; // capture and log performance (server-side flag, it can also tbe set by the client to return the profiling data) export const aixRouter = createTRPCRouter({ @@ -46,7 +46,7 @@ export const aixRouter = createTRPCRouter({ // Profiler, if requested by the caller - const _profiler = !(DEBUG_LOG_PROFILER || input.connectionOptions?.debugDispatchRequest) ? null + const _profiler = !(DEBUG_LOG_PROFILER_ON_SERVER || input.connectionOptions?.debugDispatchRequest) ? null : new PerformanceProfiler(); const _profilerCompleted = !_profiler ? null : () => { @@ -55,7 +55,7 @@ export const aixRouter = createTRPCRouter({ chatGenerateTx.addDebugProfilererData(_profiler?.getResultsData()); // print on the console, only if we have the server-side conf flag - if (DEBUG_LOG_PROFILER) + if (DEBUG_LOG_PROFILER_ON_SERVER) performanceProfilerLog('AIX Router Performance', _profiler?.getResultsData()); // clear the profiler for the next call, for resident lambdas (the profiling framework is global)