Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

Commit aaf64fa

Browse files
authored
Increase compilation memory limit to 300m (#30)
1 parent ca53781 commit aaf64fa

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

src/cpp.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use std::{
33
process::{Child, Command, Stdio},
44
};
55

6-
use crate::{error::SimulatorError, handle_process};
6+
use crate::{
7+
error::SimulatorError, handle_process, COMPILATION_MEMORY_LIMIT, COMPILATION_TIME_LIMIT,
8+
RUNTIME_MEMORY_LIMIT, RUNTIME_TIME_LIMIT,
9+
};
710

811
pub struct Runner {
912
current_dir: String,
@@ -16,11 +19,11 @@ impl Runner {
1619
let compile = Command::new("timeout".to_owned())
1720
.args([
1821
"--signal=KILL",
19-
"5",
22+
COMPILATION_TIME_LIMIT,
2023
"docker",
2124
"run",
22-
"--memory=100m",
23-
"--memory-swap=100m",
25+
&format!("--memory={}", COMPILATION_MEMORY_LIMIT),
26+
&format!("--memory-swap={}", COMPILATION_MEMORY_LIMIT),
2427
"--cpus=2",
2528
"--rm",
2629
"-v",
@@ -45,11 +48,11 @@ impl Runner {
4548
Command::new("timeout".to_owned())
4649
.args([
4750
"--signal=KILL",
48-
"10",
51+
RUNTIME_TIME_LIMIT,
4952
"docker",
5053
"run",
51-
"--memory=100m",
52-
"--memory-swap=100m",
54+
&format!("--memory={}", RUNTIME_MEMORY_LIMIT),
55+
&format!("--memory-swap={}", RUNTIME_MEMORY_LIMIT),
5356
"--cpus=1",
5457
"--rm",
5558
"-i",

src/java.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use std::{
33
process::{Child, Command, Stdio},
44
};
55

6-
use crate::{error::SimulatorError, handle_process};
6+
use crate::{
7+
error::SimulatorError, handle_process, COMPILATION_MEMORY_LIMIT, COMPILATION_TIME_LIMIT,
8+
RUNTIME_MEMORY_LIMIT, RUNTIME_TIME_LIMIT,
9+
};
710

811
pub struct Runner {
912
current_dir: String,
@@ -16,11 +19,11 @@ impl Runner {
1619
let compile = Command::new("timeout".to_owned())
1720
.args([
1821
"--signal=KILL",
19-
"5",
22+
COMPILATION_TIME_LIMIT,
2023
"docker",
2124
"run",
22-
"--memory=100m",
23-
"--memory-swap=100m",
25+
&format!("--memory={}", COMPILATION_MEMORY_LIMIT),
26+
&format!("--memory-swap={}", COMPILATION_MEMORY_LIMIT),
2427
"--cpus=1.5",
2528
"--rm",
2629
"-v",
@@ -49,11 +52,11 @@ impl Runner {
4952
Command::new("timeout".to_owned())
5053
.args([
5154
"--signal=KILL",
52-
"10",
55+
RUNTIME_TIME_LIMIT,
5356
"docker",
5457
"run",
55-
"--memory=100m",
56-
"--memory-swap=100m",
58+
&format!("--memory={}", RUNTIME_MEMORY_LIMIT),
59+
&format!("--memory-swap={}", RUNTIME_MEMORY_LIMIT),
5760
"--cpus=1",
5861
"--rm",
5962
"-i",

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub mod utils;
1818
// maximum size for log will be around 200KBs, everything after that is ignored
1919
const MAXLOGSIZE: usize = 200000;
2020
const SIGKILL: i32 = 9;
21+
const COMPILATION_TIME_LIMIT: &'static str = "5";
22+
const RUNTIME_TIME_LIMIT: &'static str = "10";
23+
const COMPILATION_MEMORY_LIMIT: &'static str = "300m";
24+
const RUNTIME_MEMORY_LIMIT: &'static str = "100m";
2125

2226
pub fn handle_process(
2327
proc: Child,

src/py.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
process::{Command, Stdio},
44
};
55

6-
use crate::error::SimulatorError;
6+
use crate::{error::SimulatorError, RUNTIME_MEMORY_LIMIT, RUNTIME_TIME_LIMIT};
77

88
pub struct Runner {
99
current_dir: String,
@@ -17,11 +17,11 @@ impl Runner {
1717
Command::new("timeout".to_owned())
1818
.args([
1919
"--signal=KILL",
20-
"10",
20+
RUNTIME_TIME_LIMIT,
2121
"docker",
2222
"run",
23-
"--memory=100m",
24-
"--memory-swap=100m",
23+
&format!("--memory={}", RUNTIME_MEMORY_LIMIT),
24+
&format!("--memory-swap={}", RUNTIME_MEMORY_LIMIT),
2525
"--cpus=1",
2626
"--rm",
2727
"-i",

0 commit comments

Comments
 (0)