Skip to content

Commit

Permalink
Merge pull request #285 from PLSE-Lab/main
Browse files Browse the repository at this point in the history
Make Interpreter Heap and Stack Size Configurable
  • Loading branch information
jurgenvinju authored Aug 24, 2023
2 parents 4bcfdae + 0f28569 commit 2e584c4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
17 changes: 16 additions & 1 deletion rascal-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,22 @@
"scopeName": "source.parametric-rascalmpl",
"path": "./syntaxes/parametric.tmGrammar.json"
}
]
],
"configuration": {
"title": "Rascal",
"properties": {
"rascal.interpreter.maxHeapSize": {
"type": ["number", "null"],
"default": null,
"description": "Provides the maximum heap space, in MB, for the Rascal interpreter"
},
"rascal.interpreter.stackSize": {
"type": ["number", "null"],
"default": null,
"description": "Provides the per-thread stack size, in MB, for the Rascal interpreter"
}
}
}
},
"scripts": {
"lsp4j:package": "cp ../rascal-lsp/target/rascal-lsp*.jar assets/jars/rascal-lsp.jar && cp ../rascal-lsp/target/lib/*.jar assets/jars/",
Expand Down
32 changes: 29 additions & 3 deletions rascal-vscode-extension/src/RascalExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,15 @@ export class RascalExtension implements vscode.Disposable {
private buildShellArgs(classPath: string[], ide: IDEServicesConfiguration, ...extraArgs: string[]) {
const shellArgs = [
calculateRascalREPLMemory()
, '-cp'
, this.buildTerminalJVMPath() + (classPath.length > 0 ? (path.delimiter + classPath.join(path.delimiter)) : ''),
];
const replStackSize = calculateRascalREPLStackSize();
if (replStackSize.length !== 0) {
shellArgs.push(replStackSize);
}
shellArgs.push(
'-cp'
, this.buildTerminalJVMPath() + (classPath.length > 0 ? (path.delimiter + classPath.join(path.delimiter)) : ''),
);
if (!this.isDeploy) {
// for development mode we always start the terminal with debuging ready to go
shellArgs.push(
Expand Down Expand Up @@ -172,6 +178,14 @@ function gb(amount: integer) {
}

function calculateRascalREPLMemory() {
const config = vscode.workspace.getConfiguration();
if (config.has('rascal.interpreter.maxHeapSize')) {
const maxHeapSize = config.get('rascal.interpreter.maxHeapSize');
if (maxHeapSize !== null) {
return `-Xmx${maxHeapSize}M`;
}
}

if (os.totalmem() >= gb(32)) {
return "-Xmx9000M";
}
Expand All @@ -182,5 +196,17 @@ function calculateRascalREPLMemory() {
if (os.totalmem() >= gb(8)) {
return "-Xmx2400M";
}
return "-Xmx800M";
return "-Xmx800M";
}

function calculateRascalREPLStackSize() {
const config = vscode.workspace.getConfiguration();
if (config.has('rascal.interpreter.stackSize')) {
const stackSize = config.get('rascal.interpreter.stackSize');
if (stackSize !== null) {
return `-Xss${stackSize}M`;
}
}

return "";
}

0 comments on commit 2e584c4

Please sign in to comment.