Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -12,8 +12,8 @@
|
||||
//! Bedarf füllt sie die GPU ([`Need::vram_mb`] = `None`).
|
||||
//! - Instanzen mit laufenden Anfragen werden nie entladen.
|
||||
//! - Passt ein Modell nicht, werden unbenutzte Instanzen entladen, die am
|
||||
//! längsten unbenutzte zuerst. `High` darf das sofort, `Normal` und `Low`
|
||||
//! erst nach einer Schonfrist.
|
||||
//! längsten unbenutzte zuerst. `High` darf das sofort, `Normal` und `Low`,
|
||||
//! wenn die Instanz oder die Anfrage die kurze Schonfrist hinter sich hat.
|
||||
//! - Wartende Anfragen werden nach Priorität und Alter bedient. Wer nicht
|
||||
//! bedient werden kann, sperrt seine GPUs für alle, die nach ihm kommen:
|
||||
//! Freigemachter Speicher bleibt dem, für den er freigemacht wurde.
|
||||
@ -38,8 +38,10 @@ pub struct Settings {
|
||||
pub max_wait: Duration,
|
||||
/// Wartezeit, nach der `Low` als `Normal` zählt (`0` = kein Aging).
|
||||
pub aging_step: Duration,
|
||||
/// Wie lange eine Instanz unbenutzt sein muss, bevor `Normal` und `Low`
|
||||
/// sie verdrängen dürfen. `High` wartet nicht.
|
||||
/// Schonfrist: `Normal` und `Low` dürfen eine unbenutzte Instanz verdrängen,
|
||||
/// wenn sie so lange unbenutzt ist oder die Anfrage selbst so lange wartet.
|
||||
/// Das zweite verhindert, dass ein immer wieder kurz benutztes Modell
|
||||
/// Wartende beliebig lange aussperrt (#1269). `High` wartet nicht.
|
||||
pub evict_min_idle: Duration,
|
||||
}
|
||||
|
||||
@ -50,7 +52,7 @@ impl Default for Settings {
|
||||
max_waiting: 32,
|
||||
max_wait: Duration::from_secs(300),
|
||||
aging_step: Duration::from_secs(60),
|
||||
evict_min_idle: Duration::from_secs(60),
|
||||
evict_min_idle: Duration::from_secs(5),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -578,6 +580,8 @@ impl Planner {
|
||||
fn victims(&self, job: &Job, claim: Claim, priority: Priority, now: Instant) -> Vec<InstId> {
|
||||
let gpus = &job.need.gpus;
|
||||
let unloading = |i: &Inst| i.state == InstState::Unloading;
|
||||
let grace = self.settings.evict_min_idle;
|
||||
let patient_enough = now.saturating_duration_since(job.enqueued) >= grace;
|
||||
if self.fits(gpus, claim, &|_, i| unloading(i)) {
|
||||
return Vec::new();
|
||||
}
|
||||
@ -590,8 +594,8 @@ impl Planner {
|
||||
&& i.unload_blocked_until.is_none_or(|t| now >= t)
|
||||
&& i.gpus.iter().any(|g| gpus.contains(g))
|
||||
&& (priority == Priority::High
|
||||
|| now.saturating_duration_since(i.last_used)
|
||||
>= self.settings.evict_min_idle)
|
||||
|| patient_enough
|
||||
|| now.saturating_duration_since(i.last_used) >= grace)
|
||||
})
|
||||
.map(|(id, i)| (i.last_used, *id))
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user