Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rosetta): propagate max heap size to worker threads #3002

Merged
merged 1 commit into from
Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/jsii-rosetta/lib/commands/extract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as os from 'os';
import * as path from 'path';
import * as ts from 'typescript';
import * as v8 from 'v8';

import { loadAssemblies, allTypeScriptSnippets } from '../jsii/assemblies';
import * as logging from '../logging';
Expand Down Expand Up @@ -210,6 +211,12 @@ async function workerBasedTranslateAll(
): Promise<import('./extract_worker').TranslateResponse> {
return new Promise((resolve, reject) => {
const wrk = new worker.Worker(path.join(__dirname, 'extract_worker.js'), {
resourceLimits: {
// Note: V8 heap statistics are expressed in bytes, so we divide by 1MiB (1,048,576 bytes)
maxOldGenerationSizeMb: Math.ceil(
v8.getHeapStatistics().heap_size_limit / 1_048_576,
),
},
workerData: request,
});
wrk.on('message', resolve);
Expand Down