From fe20bdfbd0ad8dfa32a276ff0298f32998414f4d Mon Sep 17 00:00:00 2001 From: Himit_ZH <372347736@qq.com> Date: Tue, 30 Nov 2021 12:33:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3judgeserver=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/top/hcode/hoj/config/StartupRunner.java | 4 ++-- .../java/top/hcode/hoj/controller/JudgeController.java | 1 - .../src/main/java/top/hcode/hoj/judge/JudgeRun.java | 4 ++-- .../src/main/java/top/hcode/hoj/judge/SandboxRun.java | 2 +- .../hcode/hoj/service/impl/ContestRecordServiceImpl.java | 6 +++--- .../JudgeServer/src/main/resources/application.yml | 8 ++++---- .../JudgeServer/src/main/resources/bootstrap.yml | 4 ++-- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/config/StartupRunner.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/config/StartupRunner.java index 8d46cf23..ae544c32 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/config/StartupRunner.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/config/StartupRunner.java @@ -49,7 +49,7 @@ public class StartupRunner implements CommandLineRunner { public void run(String... args) { if (maxTaskNum == -1) { - maxTaskNum = cpuNum * 2; + maxTaskNum = cpuNum + 1; } if (ip.equals("-1")) { ip = IpUtils.getLocalIpv4Address(); @@ -68,7 +68,7 @@ public class StartupRunner implements CommandLineRunner { boolean isOk2 = true; if (openRemoteJudge) { if (maxRemoteTaskNum == -1) { - maxRemoteTaskNum = (cpuNum * 2 ) * 2; + maxRemoteTaskNum = cpuNum * 2 + 1; } isOk2 = judgeServerService.save(new JudgeServer() .setCpuCore(cpuNum) diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java index 181ccec5..de6fa959 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/controller/JudgeController.java @@ -128,7 +128,6 @@ public class JudgeController { } // 进行判题操作 Problem problem = problemService.getById(judge.getPid()); - Judge finalJudge = judgeService.Judge(problem, judge); // 更新该次提交 diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeRun.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeRun.java index 8efb7a6e..08412a0b 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeRun.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeRun.java @@ -73,8 +73,8 @@ public class JudgeRun { // 使用线程池开启多线程测试每一测试输入数据 ExecutorService threadPool = new ThreadPoolExecutor( cpuNum, // 核心线程数 - cpuNum * 2, // 最大线程数。最多几个线程并发。 - 3,//当非核心线程无任务时,几秒后结束该线程 + cpuNum + 1, // 最大线程数。最多几个线程并发。 + 1,//当非核心线程无任务时,几秒后结束该线程 TimeUnit.SECONDS,// 结束线程时间单位 new LinkedBlockingDeque<>(200), //阻塞队列,限制等候线程数 Executors.defaultThreadFactory(), diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/SandboxRun.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/SandboxRun.java index 6b09c105..a762934c 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/SandboxRun.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/SandboxRun.java @@ -68,7 +68,7 @@ public class SandboxRun { public static final HashMap RESULT_MAP_STATUS = new HashMap<>(); - private static final int maxProcessNumber = 128; + private static final int maxProcessNumber = 32; private static final int TIME_LIMIT_MS = 16000; diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java index 7fb56505..c0342e6f 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/ContestRecordServiceImpl.java @@ -37,7 +37,6 @@ public class ContestRecordServiceImpl extends ServiceImpl updateWrapper = new UpdateWrapper<>(); // 如果是AC @@ -61,6 +60,7 @@ public class ContestRecordServiceImpl extends ServiceImpl 0; if (!result) { @@ -74,7 +74,7 @@ public class ContestRecordServiceImpl extends ServiceImpl 0; if (result) { - return; + break; } else { attemptNumber++; retryable = attemptNumber < 8; @@ -83,7 +83,7 @@ public class ContestRecordServiceImpl extends ServiceImpl