From 5e8bb13ecd10de2b8a993a65368c23728abd5938 Mon Sep 17 00:00:00 2001 From: Geoffroy Couprie Date: Tue, 6 Aug 2024 17:10:32 +0200 Subject: [PATCH] do not return rss --- router-bridge/js-src/plan_worker.ts | 16 ---------------- router-bridge/src/planner.rs | 5 ++++- router-bridge/src/worker.rs | 2 ++ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/router-bridge/js-src/plan_worker.ts b/router-bridge/js-src/plan_worker.ts index 7b0bb895..858691da 100644 --- a/router-bridge/js-src/plan_worker.ts +++ b/router-bridge/js-src/plan_worker.ts @@ -29,9 +29,6 @@ declare let logger: { }; export interface MemoryUsage { - /* The number of bytes of the current Deno's process resident set size, - * which is the amount of memory occupied in main memory (RAM). */ - //rss: number; /** The total size of the heap for V8, in bytes. */ heapTotal: number; /** The amount of the heap used for V8, in bytes. */ @@ -132,7 +129,6 @@ type ApiSchemaResult = { schema: string; }; type MemoryUsageResult = { - //rss: number; heapTotal: number; heapUsed: number; external: number; @@ -324,25 +320,13 @@ async function run() { await send({ id, payload: subgraphs }); break; case PlannerEventKind.GetHeapStatistics: - logger.info(`received event: ${JSON.stringify(event)}`); - - //const mem = Deno.memoryUsage(); const mem = memoryUsage(); - logger.info(`got memoryUsage`); const result: MemoryUsageResult = { - //rss: mem.rss, heapTotal: mem.heapTotal, heapUsed: mem.heapUsed, external: mem.external, }; - /*const result: MemoryUsageResult = { - rss: 1, - heapTotal: 2, - heapUsed: 3, - external: 4, - };*/ - logger.info(`memoryUsage: ${JSON.stringify(result)}`); await send({ id, payload: result }); break; diff --git a/router-bridge/src/planner.rs b/router-bridge/src/planner.rs index c4ab88cf..cbaabf90 100644 --- a/router-bridge/src/planner.rs +++ b/router-bridge/src/planner.rs @@ -400,10 +400,13 @@ where #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] +/// deno's heap statistics pub struct HeapStatistics { - //pub rss: u64, + /// total size of the heap for V8, in bytes pub heap_total: u64, + /// amount of the heap used for V8, in bytes pub heap_used: u64, + /// emory, in bytes, associated with JavaScript objects outside of the JavaScript isolate pub external: u64, } diff --git a/router-bridge/src/worker.rs b/router-bridge/src/worker.rs index d54fa72e..8f9af148 100644 --- a/router-bridge/src/worker.rs +++ b/router-bridge/src/worker.rs @@ -313,6 +313,8 @@ struct MemoryUsage { external: usize, } +// from https://github.com/denoland/deno/blob/897159dc6e1b2319cf2f5f09d8d6cecc0d3175fa/runtime/ops/os/mod.rs#L329 +// tested in planner.rs #[op(v8)] fn op_runtime_memory_usage(scope: &mut v8::HandleScope<'_>) -> MemoryUsage { let mut s = v8::HeapStatistics::default();