修正judgeserver的一些参数

This commit is contained in:
Himit_ZH 2021-11-30 12:33:19 +08:00
parent b3af379eab
commit fe20bdfbd0
7 changed files with 14 additions and 15 deletions

View File

@ -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)

View File

@ -128,7 +128,6 @@ public class JudgeController {
}
// 进行判题操作
Problem problem = problemService.getById(judge.getPid());
Judge finalJudge = judgeService.Judge(problem, judge);
// 更新该次提交

View File

@ -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(),

View File

@ -68,7 +68,7 @@ public class SandboxRun {
public static final HashMap<String, Integer> 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;

View File

@ -37,7 +37,6 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
@Override
@Async
public void UpdateContestRecord(String uid, Integer score, Integer status, Long submitId, Long cid, Integer useTime) {
UpdateWrapper<ContestRecord> updateWrapper = new UpdateWrapper<>();
// 如果是AC
@ -61,6 +60,7 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
updateWrapper.set("use_time", useTime);
updateWrapper.eq("submit_id", submitId) // submit_id一定只有一个
.eq("cid", cid)
.eq("uid", uid);
boolean result = contestRecordMapper.update(null, updateWrapper) > 0;
if (!result) {
@ -74,7 +74,7 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
do {
boolean result = contestRecordMapper.update(null, updateWrapper) > 0;
if (result) {
return;
break;
} else {
attemptNumber++;
retryable = attemptNumber < 8;
@ -83,7 +83,7 @@ public class ContestRecordServiceImpl extends ServiceImpl<ContestRecordMapper, C
break;
}
try {
Thread.sleep(1000);
Thread.sleep(300);
} catch (InterruptedException e) {
log.error(e.getMessage());
}

View File

@ -6,9 +6,9 @@ spring:
url: jdbc:mysql://${hoj.db.public-host}:${hoj.db.port}/${hoj.db.name}?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
initial-size: 5 # 初始化时建立物理连接的个数。初始化发生在显示调用init方法或者第一次getConnection时
min-idle: 10 # 最小连接池数量
maxActive: 20 # 最大连接池数量
initial-size: 10 # 初始化时建立物理连接的个数。初始化发生在显示调用init方法或者第一次getConnection时
min-idle: 20 # 最小连接池数量
maxActive: 40 # 最大连接池数量
maxWait: 60000 # 获取连接时最大等待时间单位毫秒。配置了maxWait之后缺省启用公平锁并发效率会有所下降如果需要可以通过配置
timeBetweenEvictionRunsMillis: 60000 # 关闭空闲连接的检测时间间隔.Destroy线程会检测连接的间隔时间如果连接空闲时间大于等于minEvictableIdleTimeMillis则关闭物理连接。
minEvictableIdleTimeMillis: 300000 # 连接的最小生存时间.连接保持空闲而不被驱逐的最小时间
@ -24,7 +24,7 @@ spring:
asyncInit: true # 异步初始化策略
remove-abandoned: true # 是否自动回收超时连接
remove-abandoned-timeout: 1800 # 超时时间(以秒数为单位)
transaction-query-timeout: 6000 # 事务超时时间
transaction-query-timeout: 10000 # 事务超时时间
filters: stat,wall,log4j #数据库日志
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500

View File

@ -1,12 +1,12 @@
hoj-judge-server:
max-task-num: ${MAX_TASK_NUM:-1} # -1表示最大并行任务数为cpu核心数*2
max-task-num: ${MAX_TASK_NUM:-1} # -1表示最大并行任务数为cpu核心数+1
ip: ${JUDGE_SERVER_IP:127.0.0.1} # -1表示使用默认本地ipv4若是部署其它服务器务必使用公网ip
port: ${JUDGE_SERVER_PORT:8088} # 端口号
name: ${JUDGE_SERVER_NAME:hoj-judger-1} # 判题机名字 唯一不可重复!!!
nacos-url: ${NACOS_URL:127.0.0.1:8848} # nacos地址
remote-judge:
open: ${REMOTE_JUDGE_OPEN:true} # 当前判题服务器是否开启远程虚拟判题功能
max-task-num: ${REMOTE_JUDGE_MAX_TASK_NUM:-1} # -1表示最大并行任务数为(cpu核心数*2)*2
max-task-num: ${REMOTE_JUDGE_MAX_TASK_NUM:-1} # -1表示最大并行任务数为cpu核心数*2+1
server:
port: ${hoj-judge-server.port}
spring: