Skip to content

Commit 614886c

Browse files
authored
Give Node more memory (#36)
Turns out that Node requires about 89 MiB of RAM _just_ to start. The VM itself also consumes about 31 MiB of memory, so we need to account for both to avoid submissions erroring out prematurely.
1 parent f2faa13 commit 614886c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/jail/options.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ use crate::args;
1414
const DEFAULT_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 16 * 1024 * 1024;
1515
const RUBY_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 56 * 1024 * 1024;
1616
const GO_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 512 * 1024 * 1024;
17+
const NODE_EXTRA_MEMORY_SIZE_IN_BYTES: u64 = 89 * 1024 * 1024;
1718

1819
// These are obtained by running an "empty" and measuring
1920
// its memory consumption, as reported by omegajail.
2021
const JAVA_VM_MEMORY_SIZE_IN_BYTES: u64 = 47 * 1024 * 1024;
2122
const CLR_VM_MEMORY_SIZE_IN_BYTES: u64 = 20 * 1024 * 1024;
2223
const RUBY_VM_MEMORY_SIZE_IN_BYTES: u64 = 12 * 1024 * 1024;
24+
const NODE_VM_MEMORY_SIZE_IN_BYTES: u64 = 31 * 1024 * 1024;
2325

2426
// This is the result of executing the following Java code:
2527
//
@@ -494,6 +496,8 @@ impl JailOptions {
494496
}
495497
args::Language::JavaScript => {
496498
seccomp_profile_name = String::from("js");
499+
extra_memory_size_in_bytes = NODE_EXTRA_MEMORY_SIZE_IN_BYTES;
500+
vm_memory_size_in_bytes = NODE_VM_MEMORY_SIZE_IN_BYTES;
497501
mounts.push(MountArgs {
498502
source: Some(root.join("root-js")),
499503
target: rootfs.join("opt/nodejs"),
@@ -509,6 +513,8 @@ impl JailOptions {
509513
}
510514
args::Language::KarelJava | args::Language::KarelPascal => {
511515
seccomp_profile_name = String::from("js");
516+
extra_memory_size_in_bytes = NODE_EXTRA_MEMORY_SIZE_IN_BYTES;
517+
vm_memory_size_in_bytes = NODE_VM_MEMORY_SIZE_IN_BYTES;
512518
mounts.push(MountArgs {
513519
source: Some(root.join("root-js")),
514520
target: rootfs.join("opt/nodejs"),
@@ -698,6 +704,8 @@ impl JailOptions {
698704
}
699705
args::Language::JavaScript => {
700706
seccomp_profile_name = String::from("js");
707+
extra_memory_size_in_bytes = NODE_EXTRA_MEMORY_SIZE_IN_BYTES;
708+
vm_memory_size_in_bytes = NODE_VM_MEMORY_SIZE_IN_BYTES;
701709
mounts.push(MountArgs {
702710
source: Some(root.join("root-js")),
703711
target: rootfs.join("opt/nodejs"),

0 commit comments

Comments
 (0)