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

Commit

Permalink
Increase compilation memory limit to 300m (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
dipeshkaphle committed Mar 4, 2022
1 parent ca53781 commit aaf64fa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
17 changes: 10 additions & 7 deletions src/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::{
process::{Child, Command, Stdio},
};

use crate::{error::SimulatorError, handle_process};
use crate::{
error::SimulatorError, handle_process, COMPILATION_MEMORY_LIMIT, COMPILATION_TIME_LIMIT,
RUNTIME_MEMORY_LIMIT, RUNTIME_TIME_LIMIT,
};

pub struct Runner {
current_dir: String,
Expand All @@ -16,11 +19,11 @@ impl Runner {
let compile = Command::new("timeout".to_owned())
.args([
"--signal=KILL",
"5",
COMPILATION_TIME_LIMIT,
"docker",
"run",
"--memory=100m",
"--memory-swap=100m",
&format!("--memory={}", COMPILATION_MEMORY_LIMIT),
&format!("--memory-swap={}", COMPILATION_MEMORY_LIMIT),
"--cpus=2",
"--rm",
"-v",
Expand All @@ -45,11 +48,11 @@ impl Runner {
Command::new("timeout".to_owned())
.args([
"--signal=KILL",
"10",
RUNTIME_TIME_LIMIT,
"docker",
"run",
"--memory=100m",
"--memory-swap=100m",
&format!("--memory={}", RUNTIME_MEMORY_LIMIT),
&format!("--memory-swap={}", RUNTIME_MEMORY_LIMIT),
"--cpus=1",
"--rm",
"-i",
Expand Down
17 changes: 10 additions & 7 deletions src/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::{
process::{Child, Command, Stdio},
};

use crate::{error::SimulatorError, handle_process};
use crate::{
error::SimulatorError, handle_process, COMPILATION_MEMORY_LIMIT, COMPILATION_TIME_LIMIT,
RUNTIME_MEMORY_LIMIT, RUNTIME_TIME_LIMIT,
};

pub struct Runner {
current_dir: String,
Expand All @@ -16,11 +19,11 @@ impl Runner {
let compile = Command::new("timeout".to_owned())
.args([
"--signal=KILL",
"5",
COMPILATION_TIME_LIMIT,
"docker",
"run",
"--memory=100m",
"--memory-swap=100m",
&format!("--memory={}", COMPILATION_MEMORY_LIMIT),
&format!("--memory-swap={}", COMPILATION_MEMORY_LIMIT),
"--cpus=1.5",
"--rm",
"-v",
Expand Down Expand Up @@ -49,11 +52,11 @@ impl Runner {
Command::new("timeout".to_owned())
.args([
"--signal=KILL",
"10",
RUNTIME_TIME_LIMIT,
"docker",
"run",
"--memory=100m",
"--memory-swap=100m",
&format!("--memory={}", RUNTIME_MEMORY_LIMIT),
&format!("--memory-swap={}", RUNTIME_MEMORY_LIMIT),
"--cpus=1",
"--rm",
"-i",
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ pub mod utils;
// maximum size for log will be around 200KBs, everything after that is ignored
const MAXLOGSIZE: usize = 200000;
const SIGKILL: i32 = 9;
const COMPILATION_TIME_LIMIT: &'static str = "5";
const RUNTIME_TIME_LIMIT: &'static str = "10";
const COMPILATION_MEMORY_LIMIT: &'static str = "300m";
const RUNTIME_MEMORY_LIMIT: &'static str = "100m";

pub fn handle_process(
proc: Child,
Expand Down
8 changes: 4 additions & 4 deletions src/py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
process::{Command, Stdio},
};

use crate::error::SimulatorError;
use crate::{error::SimulatorError, RUNTIME_MEMORY_LIMIT, RUNTIME_TIME_LIMIT};

pub struct Runner {
current_dir: String,
Expand All @@ -17,11 +17,11 @@ impl Runner {
Command::new("timeout".to_owned())
.args([
"--signal=KILL",
"10",
RUNTIME_TIME_LIMIT,
"docker",
"run",
"--memory=100m",
"--memory-swap=100m",
&format!("--memory={}", RUNTIME_MEMORY_LIMIT),
&format!("--memory-swap={}", RUNTIME_MEMORY_LIMIT),
"--cpus=1",
"--rm",
"-i",
Expand Down

0 comments on commit aaf64fa

Please sign in to comment.