Skip to content

Commit

Permalink
do not return rss
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Aug 6, 2024
1 parent 9156d88 commit 5e8bb13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
16 changes: 0 additions & 16 deletions router-bridge/js-src/plan_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -132,7 +129,6 @@ type ApiSchemaResult = {
schema: string;
};
type MemoryUsageResult = {
//rss: number;
heapTotal: number;
heapUsed: number;
external: number;
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion router-bridge/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
2 changes: 2 additions & 0 deletions router-bridge/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5e8bb13

Please sign in to comment.