Skip to content

Commit

Permalink
feat(iris): serialize testcase judging and limit output size (#2258)
Browse files Browse the repository at this point in the history
* feat(be): submission controller for load test

* feat(iris): serialize testcase judging (#2255)

feat(be): serialize testcase judging
- 병렬적으로 처리되고 있던 tc 채점을 직렬화합니다.

* fix(infra): change iris spec for serialzation

* feat(iris): limit judge result output (#2256)

* feat(iris): limit judge result output

* feat(iris): set limit 1MB

* Revert "feat(be): submission controller for load test"

This reverts commit 449b44e.

* fix(infra): update iris spec container after load-test

* fix(infra): change the number of iris and api container

---------

Co-authored-by: donghun1214 <[email protected]>
  • Loading branch information
Jaehyeon1020 and donghun1214 authored Dec 7, 2024
1 parent 59d1673 commit b8e55c0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions apps/infra/production/codedang/codedang_service_client.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module "client_api" {
ecs_service = {
name = "Codedang-Client-Api-Service"
cluster_arn = module.codedang_api.ecs_cluster.arn
desired_count = 2
desired_count = 3
load_balancer = {
container_name = "Codedang-Client-Api"
container_port = 4000
Expand All @@ -116,7 +116,7 @@ module "client_api" {
}

appautoscaling_target = {
min_capacity = 2
min_capacity = 3
max_capacity = 8
resource_id = {
cluster_name = module.codedang_api.ecs_cluster.name
Expand Down
8 changes: 4 additions & 4 deletions apps/infra/production/codedang/codedang_service_iris.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module "iris" {
task_definition = {
family = "Codedang-Iris-Api"
cpu = 512
memory = 1700
memory = 512

container_definitions = jsonencode([
jsondecode(templatefile("container_definitions/iris.json", {
Expand Down Expand Up @@ -75,12 +75,12 @@ module "iris" {
ecs_service = {
name = "Codedang-Iris-Service"
cluster_arn = module.codedang_iris.ecs_cluster.arn
desired_count = 2
desired_count = 6
}

appautoscaling_target = {
min_capacity = 2
max_capacity = 8
min_capacity = 6
max_capacity = 6
resource_id = {
cluster_name = module.codedang_iris.ecs_cluster.name
}
Expand Down
2 changes: 2 additions & 0 deletions apps/iris/src/common/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ const (
EXCHANGE = "judger-exchange"
RESULT_KEY = "result"
)

const MAX_OUTPUT = 1048576 // 1MB
15 changes: 7 additions & 8 deletions apps/iris/src/handler/judge-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,9 @@ func (j *JudgeHandler) Handle(id string, data []byte, hidden bool, out chan Judg
}

tcNum := tc.Count()
cnt := make(chan int)
for i := 0; i < tcNum; i++ {
go j.judgeTestcase(i, dir, validReq, tc.Elements[i], out, cnt)
}

for i := 0; i < tcNum; i++ {
<-cnt
j.judgeTestcase(i, dir, validReq, tc.Elements[i], out)
// j.logger.Log(logger.DEBUG, fmt.Sprintf("Testcase %d judged", i))
}
}

Expand Down Expand Up @@ -324,7 +320,7 @@ func (j *JudgeHandler) getTestcase(traceCtx context.Context, out chan<- result.C
}

func (j *JudgeHandler) judgeTestcase(idx int, dir string, validReq *Request,
tc loader.Element, out chan JudgeResultMessage, cnt chan int) {
tc loader.Element, out chan JudgeResultMessage) {

var accepted bool

Expand All @@ -351,6 +347,10 @@ func (j *JudgeHandler) judgeTestcase(idx int, dir string, validReq *Request,
res.SetJudgeExecResult(runResult.ExecResult)
res.Output = string(runResult.Output)

if len(res.Output) > constants.MAX_OUTPUT {
res.Output = res.Output[:constants.MAX_OUTPUT]
}

if runResult.ExecResult.ResultCode != sandbox.RUN_SUCCESS {
res.SetJudgeResultCode(SandboxResultCodeToJudgeResultCode(runResult.ExecResult.ResultCode))
goto Send
Expand All @@ -376,5 +376,4 @@ Send:
// j.logger.Log(logger.DEBUG, string(marshaledRes))
out <- JudgeResultMessage{marshaledRes, ParseError(res)}
}
cnt <- 1
}

0 comments on commit b8e55c0

Please sign in to comment.