From e50de7cac1a71feb6cc0f7261237ec3a822bc047 Mon Sep 17 00:00:00 2001 From: Owen Greenhalgh Date: Thu, 30 Apr 2026 15:35:41 +0100 Subject: [PATCH] revert gc observer --- server/src/utils/memoryMonitor.ts | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/server/src/utils/memoryMonitor.ts b/server/src/utils/memoryMonitor.ts index 2710949f5..cca806d85 100644 --- a/server/src/utils/memoryMonitor.ts +++ b/server/src/utils/memoryMonitor.ts @@ -5,7 +5,7 @@ * Uses Axiom logger so metrics are queryable via type: "memory_log". */ -import { monitorEventLoopDelay, PerformanceObserver } from "node:perf_hooks"; +import { monitorEventLoopDelay } from "node:perf_hooks"; import { logger } from "../external/logtail/logtailUtils.js"; // Event loop lag histogram — samples at 100ms resolution at the C++ level. @@ -13,21 +13,6 @@ import { logger } from "../external/logtail/logtailUtils.js"; const lagHistogram = monitorEventLoopDelay({ resolution: 100 }); lagHistogram.enable(); -// GC pause tracking. observes V8 GC events and accumulates count, max and total -// pause duration. Reset alongside the lag histogram on each emit so windows align. -let gcCount = 0; -let gcMaxMs = 0; -let gcTotalMs = 0; - -const gcObserver = new PerformanceObserver((list) => { - for (const entry of list.getEntries()) { - gcCount += 1; - gcTotalMs += entry.duration; - if (entry.duration > gcMaxMs) gcMaxMs = entry.duration; - } -}); -gcObserver.observe({ entryTypes: ["gc"] }); - /** Get the current mean event loop lag in milliseconds. */ export function getEventLoopLagMs(): number { return Math.round((lagHistogram.mean / 1e6) * 10) / 10; @@ -53,15 +38,8 @@ function logMemoryUsage(label: string) { const lagMaxMs = Math.round((lagHistogram.max / 1e6) * 10) / 10; lagHistogram.reset(); - const localGcCount = gcCount; - const localGcMaxMs = Math.round(gcMaxMs * 10) / 10; - const localGcTotalMs = Math.round(gcTotalMs * 10) / 10; - gcCount = 0; - gcMaxMs = 0; - gcTotalMs = 0; - logger.info( - `memory_log, rss: ${toMB(mem.rss)}MB, heapUsed: ${toMB(mem.heapUsed)}MB, eventLoopLagP99: ${lagP99Ms}ms, eventLoopLagMax: ${lagMaxMs}ms, gcMax: ${localGcMaxMs}ms`, + `memory_log, rss: ${toMB(mem.rss)}MB, heapUsed: ${toMB(mem.heapUsed)}MB, eventLoopLagP99: ${lagP99Ms}ms, eventLoopLagMax: ${lagMaxMs}ms`, { type: "memory_log", data: { @@ -76,9 +54,6 @@ function logMemoryUsage(label: string) { eventLoopLagMeanMs: lagMeanMs, eventLoopLagP99Ms: lagP99Ms, eventLoopLagMaxMs: lagMaxMs, - gcCount: localGcCount, - gcMaxMs: localGcMaxMs, - gcTotalMs: localGcTotalMs, }, }, );