mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-17 12:21:59 +00:00
运行名额改成给交互留底、其余可借(用户拍板):交互留底缺省全站上限的 1/4、至少 1、至多全站上限减 1,应用、定时、系统三类合起来永远用不到留底;三类各自的上限缺省 = 全站上限 − 留底(设置里可调小),没人问数据时评测能开满;交互上限缺省 = 全站上限;等名额照旧按优先级、同级先来先得。存着的设置原样存、缺省按全站上限和留底现算;留底不小于全站上限时 422。设置页「运行并发」加「给交互留底」一项,写明留底和借用是什么,README 同步。补测试:缺省值、空闲时系统类借满到 全站 − 留底、留底不借给应用类、问数据一来马上拿到留底;多进程端到端加 5b(评测借满时问数据拿留底、不等评测跑完)
This commit is contained in:
@@ -6,6 +6,10 @@ export const CONCURRENCY_TEXT = {
|
||||
title: '运行并发',
|
||||
hint: '全站同时执行的运行按来源分四类,各有上限和优先级:名额满了时先给优先级高的一类,已经在执行的不打断。多进程部署时几个进程合起来算',
|
||||
maxTotal: '全站同时运行的上限',
|
||||
reserve: '给交互留底',
|
||||
reserveHint: '全站名额里永远留给交互类的个数,应用、定时、系统用不到这一部分:有人问数据、试运行时总有名额。至多全站上限减 1',
|
||||
borrow: (n: number) => `应用、定时、系统合起来最多借用 ${n} 个名额(全站上限减留底):没人问数据时评测可以同时多开几题`,
|
||||
limitHint: '各类的上限可以调小;应用、定时、系统再大也借不到留底那一部分',
|
||||
limit: '上限',
|
||||
priority: '优先级',
|
||||
priorityHint: '数字大的先拿到空出来的名额(0 到 100)',
|
||||
|
||||
@@ -8,17 +8,19 @@ import { atLeast, usePrincipal } from '../store/auth'
|
||||
|
||||
const T = CONCURRENCY_TEXT
|
||||
type Klass = (typeof CONCURRENCY_CLASSES)[number]
|
||||
interface Draft { total: string; limits: Record<Klass, string>; priorities: Record<Klass, string> }
|
||||
interface Draft { total: string; reserve: string; limits: Record<Klass, string>; priorities: Record<Klass, string> }
|
||||
type Now = Partial<Record<Klass, { running?: number; waiting?: number }>>
|
||||
|
||||
const draftOf = (group: Record<string, any> | undefined): Draft => ({
|
||||
total: group?.max_total == null ? '' : String(group.max_total),
|
||||
reserve: group?.interactive_reserve == null ? '' : String(group.interactive_reserve),
|
||||
limits: Object.fromEntries(CONCURRENCY_CLASSES.map((k) => [k, String(group?.classes?.[k]?.limit ?? '')])) as Record<Klass, string>,
|
||||
priorities: Object.fromEntries(CONCURRENCY_CLASSES.map((k) => [k, String(group?.classes?.[k]?.priority ?? '')])) as Record<Klass, string>,
|
||||
})
|
||||
|
||||
const changedCount = (a: Draft, b: Draft): number =>
|
||||
(a.total.trim() !== b.total ? 1 : 0)
|
||||
+ (a.reserve.trim() !== b.reserve ? 1 : 0)
|
||||
+ CONCURRENCY_CLASSES.filter((k) => a.limits[k].trim() !== b.limits[k]).length
|
||||
+ CONCURRENCY_CLASSES.filter((k) => a.priorities[k].trim() !== b.priorities[k]).length
|
||||
|
||||
@@ -62,6 +64,7 @@ export function ConcurrencySettingsSection() {
|
||||
try {
|
||||
const value = {
|
||||
max_total: Number(cur.total.trim()),
|
||||
interactive_reserve: Number(cur.reserve.trim()),
|
||||
classes: Object.fromEntries(CONCURRENCY_CLASSES.map((k) => [k, {
|
||||
limit: Number(cur.limits[k].trim()), priority: Number(cur.priorities[k].trim()),
|
||||
}])),
|
||||
@@ -80,6 +83,8 @@ export function ConcurrencySettingsSection() {
|
||||
}
|
||||
|
||||
if (loadError || !cur) return null
|
||||
// 借用的上限按存着的算(服务端生效的那份),改到一半的输入不跟着跳
|
||||
const borrow = saved && saved.total !== '' && saved.reserve !== '' ? Math.max(0, Number(saved.total) - Number(saved.reserve)) : null
|
||||
const edit = (patch: Partial<Draft>) => {
|
||||
setError(null)
|
||||
setDraft({ ...cur, ...patch, limits: { ...cur.limits, ...(patch.limits ?? {}) },
|
||||
@@ -89,12 +94,21 @@ export function ConcurrencySettingsSection() {
|
||||
<section data-concurrency-settings="">
|
||||
<SectionBar title={T.title} hint={T.hint} />
|
||||
<fieldset disabled={!admin || saving} className="m-0 min-w-0 space-y-3 border-0 p-0">
|
||||
<Field label={T.maxTotal} htmlFor="pref-concurrency-total">
|
||||
{(p) => (
|
||||
<input {...p} className="field tnum max-w-40" inputMode="numeric" value={cur.total}
|
||||
onChange={(e) => edit({ total: e.target.value })} data-concurrency-setting="max_total" />
|
||||
)}
|
||||
</Field>
|
||||
<div className="grid grid-cols-2 gap-3 max-sm:grid-cols-1">
|
||||
<Field label={T.maxTotal} htmlFor="pref-concurrency-total">
|
||||
{(p) => (
|
||||
<input {...p} className="field tnum max-w-40" inputMode="numeric" value={cur.total}
|
||||
onChange={(e) => edit({ total: e.target.value })} data-concurrency-setting="max_total" />
|
||||
)}
|
||||
</Field>
|
||||
<Field label={T.reserve} htmlFor="pref-concurrency-reserve" hint={T.reserveHint}>
|
||||
{(p) => (
|
||||
<input {...p} className="field tnum max-w-40" inputMode="numeric" value={cur.reserve}
|
||||
onChange={(e) => edit({ reserve: e.target.value })} data-concurrency-setting="interactive_reserve" />
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
{borrow != null && <p className="text-2xs text-dim" data-concurrency-borrow="">{T.borrow(borrow)}</p>}
|
||||
<div className="space-y-2">
|
||||
{CONCURRENCY_CLASSES.map((k) => {
|
||||
const info = T.classes[k]
|
||||
@@ -106,7 +120,7 @@ export function ConcurrencySettingsSection() {
|
||||
<div className="text-2xs leading-relaxed text-faint">{info.hint}</div>
|
||||
{live && <div className="text-2xs text-dim" data-concurrency-now={k}>{T.now(live.running ?? 0, live.waiting ?? 0)}</div>}
|
||||
</div>
|
||||
<Field label={T.limit} htmlFor={`pref-concurrency-${k}-limit`}>
|
||||
<Field label={T.limit} htmlFor={`pref-concurrency-${k}-limit`} hint={k === 'app' ? T.limitHint : undefined}>
|
||||
{(p) => (
|
||||
<input {...p} className="field tnum max-w-32" inputMode="numeric" value={cur.limits[k]}
|
||||
onChange={(e) => edit({ limits: { [k]: e.target.value } as Record<Klass, string> })}
|
||||
|
||||
Reference in New Issue
Block a user