CPU limit s -> ns

This commit is contained in:
criyle 2020-03-04 23:27:55 -05:00
parent eb5dfec701
commit 51ad40a869
3 changed files with 11 additions and 11 deletions

View File

@ -71,8 +71,8 @@ interface Cmd {
files?: (LocalFile | MemoryFile | PreparedFile | Pipe | null)[];
// limitations
cpuLimit?: number; // s
realCpuLimit?: number; // s
cpuLimit?: number; // ns
realCpuLimit?: number; // ns
memoryLimit?: number; // byte
procLimit?: number;
@ -141,7 +141,7 @@ Single (Require `apt install g++` inside the container):
"name": "stderr",
"max": 10240
}],
"cpuLimit": 10,
"cpuLimit": 10000000000,
"memoryLimit": 104857600,
"procLimit": 50,
"copyIn": {
@ -186,7 +186,7 @@ Multiple:
"name": "stderr",
"max": 10240
}],
"cpuLimit": 1,
"cpuLimit": 1000000000,
"memoryLimit": 1048576,
"procLimit": 50,
"copyIn": {
@ -204,7 +204,7 @@ Multiple:
"name": "stderr",
"max": 10240
}],
"cpuLimit": 1,
"cpuLimit": 1000000000,
"memoryLimit": 1048576,
"procLimit": 50,
"copyOut": ["stdout", "stderr"]

View File

@ -15,10 +15,10 @@ type cmd struct {
Env []string `json:"env,omitempty"`
Files []*cmdFile `json:"files,omitempty"`
CPULimit float64 `json:"cpuLimit"`
RealCPULimit float64 `json:"realCpuLimit"`
MemoryLimit uint64 `json:"memoryLimit"`
ProcLimit uint64 `json:"procLimit"`
CPULimit uint64 `json:"cpuLimit"`
RealCPULimit uint64 `json:"realCpuLimit"`
MemoryLimit uint64 `json:"memoryLimit"`
ProcLimit uint64 `json:"procLimit"`
CopyIn map[string]cmdFile `json:"copyIn"`

View File

@ -189,8 +189,8 @@ func prepareCmd(rc cmd) (*envexec.Cmd, map[string]bool, error) {
}
w := &waiter{
timeLimit: time.Duration(rc.CPULimit * float64(time.Second)),
realTimeLimit: time.Duration(rc.RealCPULimit * float64(time.Second)),
timeLimit: time.Duration(rc.CPULimit),
realTimeLimit: time.Duration(rc.RealCPULimit),
}
return &envexec.Cmd{