Skip to content

Commit

Permalink
Remove system property from payload with Deno memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
d-gubert committed Jul 8, 2024
1 parent c3b4d2e commit 5e5c100
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 30 deletions.
4 changes: 0 additions & 4 deletions deno-runtime/lib/messenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ export async function errorResponse({ error: { message, code = -32000, data = {}
data.logs = logger.getLogs();
}

data.system = Deno.memoryUsage();

const rpc = jsonrpc.error(id, new jsonrpc.JsonRpcError(message, code, data));

await Queue.enqueue(rpc);
Expand All @@ -156,8 +154,6 @@ export async function successResponse({ id, result }: SuccessResponseDescriptor)
payload.logs = logger.getLogs();
}

payload.system = Deno.memoryUsage();

const rpc = jsonrpc.success(id, payload);

await Queue.enqueue(rpc);
Expand Down
4 changes: 0 additions & 4 deletions src/server/managers/AppRuntimeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,4 @@ export class AppRuntimeManager {
delete this.subprocesses[appId];
}
}

public getSystemRecords() {
return Object.values(this.subprocesses).map((ctl) => ({ appId: ctl.getAppId(), system: ctl.getLatestSystemRecord() }));
}
}
23 changes: 1 addition & 22 deletions src/server/runtime/deno/AppsEngineDenoRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ export function getDenoWrapperPath(): string {
}
}

// https://deno.land/[email protected]?s=Deno.MemoryUsage
export type DenoSystemUsageRecord = {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
};

export type DenoRuntimeOptions = {
timeout: number;
};
Expand All @@ -98,8 +90,6 @@ export class DenoRuntimeSubprocessController extends EventEmitter {

private state: 'uninitialized' | 'ready' | 'invalid' | 'unknown' | 'stopped';

private latestSystemRecord: DenoSystemUsageRecord | undefined;

private readonly accessors: AppAccessorManager;

private readonly api: AppApiManager;
Expand Down Expand Up @@ -212,10 +202,6 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
return this.state;
}

public getLatestSystemRecord() {
return this.latestSystemRecord;
}

public async getStatus(): Promise<AppStatus> {
// If the process has been terminated, we can't get the status
if (this.deno.exitCode !== null) {
Expand Down Expand Up @@ -496,28 +482,21 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
let result: unknown;
let error: jsonrpc.IParsedObjectError['payload']['error'] | undefined;
let logs: ILoggerStorageEntry;
let system: DenoSystemUsageRecord;

if (message.type === 'success') {
const params = message.payload.result as { value: unknown; logs?: ILoggerStorageEntry; system?: DenoSystemUsageRecord };
const params = message.payload.result as { value: unknown; logs?: ILoggerStorageEntry };
result = params.value;
logs = params.logs;
system = params.system;
} else {
error = message.payload.error;
logs = message.payload.error.data?.logs as ILoggerStorageEntry;
system = message.payload.error.data?.system as DenoSystemUsageRecord;
}

// Should we try to make sure all result messages have logs?
if (logs) {
await this.logStorage.storeEntries(logs);
}

if (system) {
this.latestSystemRecord = system;
}

this.emit(`result:${id}`, result, error);
}

Expand Down

0 comments on commit 5e5c100

Please sign in to comment.