mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 01:38:44 +00:00
improved queue length query
This commit is contained in:
1 parent
2094ab2fe8
commit
e8be6f9775
2 files changed
+110
-8
No files matched your search
@@ -98,3 +98,76 @@ order by jobs.id
|
||||
desc
|
||||
limit 100;
|
||||
|
||||
-- Generic inference jobs + legacy TTS (this is a production endpoint)
|
||||
-- UPDATED QUERY: Queues as named rows
|
||||
SELECT
|
||||
maybe_model_type as queue_type,
|
||||
count(*) as pending_job_count,
|
||||
NOW() as present_time
|
||||
FROM (
|
||||
SELECT
|
||||
token,
|
||||
maybe_model_type
|
||||
FROM generic_inference_jobs
|
||||
WHERE status IN ("pending", "attempt_failed")
|
||||
UNION
|
||||
SELECT
|
||||
token,
|
||||
maybe_model_type
|
||||
FROM generic_inference_jobs
|
||||
WHERE status IN ("started")
|
||||
AND created_at > (CURDATE() - INTERVAL 15 MINUTE)
|
||||
) as generic_inner
|
||||
GROUP BY queue_type
|
||||
UNION
|
||||
SELECT
|
||||
"legacy_tts" as queue_type,
|
||||
count(*) as pending_job_count,
|
||||
NOW() as present_time
|
||||
FROM
|
||||
(
|
||||
SELECT token
|
||||
FROM tts_inference_jobs
|
||||
WHERE status IN ("pending", "attempt_failed")
|
||||
UNION
|
||||
SELECT token
|
||||
FROM tts_inference_jobs
|
||||
WHERE status IN ("started")
|
||||
AND created_at > (CURDATE() - INTERVAL 15 MINUTE)
|
||||
) as legacy_inner
|
||||
GROUP BY queue_type
|
||||
|
||||
-- Generic inference jobs + legacy TTS (this was a production endpoint)
|
||||
-- OLD QUERY: Queues as columns
|
||||
SELECT
|
||||
(
|
||||
SELECT
|
||||
COUNT(distinct token) as generic_job_count
|
||||
FROM
|
||||
(
|
||||
SELECT token
|
||||
FROM generic_inference_jobs
|
||||
WHERE status = "started"
|
||||
AND created_at > (CURDATE() - INTERVAL 5 MINUTE)
|
||||
UNION
|
||||
SELECT token
|
||||
FROM generic_inference_jobs
|
||||
WHERE status IN ("pending", "attempt_failed")
|
||||
) as g
|
||||
) as generic_job_count,
|
||||
(
|
||||
SELECT
|
||||
COUNT(distinct token) as legacy_tts_job_count
|
||||
FROM
|
||||
(
|
||||
SELECT token
|
||||
FROM tts_inference_jobs
|
||||
WHERE status = "started"
|
||||
AND created_at > (CURDATE() - INTERVAL 5 MINUTE)
|
||||
UNION
|
||||
SELECT token
|
||||
FROM tts_inference_jobs
|
||||
WHERE status IN ("pending", "attempt_failed")
|
||||
) as t
|
||||
) as legacy_tts_job_count,
|
||||
NOW() as present_time;
|
||||
+37
-8
@@ -19,20 +19,31 @@ pub struct GetUnifiedQueueStatsSuccessResponse {
|
||||
/// During an attack, we may want this to go extremely slow.
|
||||
pub refresh_interval_millis: u64,
|
||||
|
||||
pub inference: TtsQueueStats,
|
||||
pub legacy_tts: TtsQueueStats,
|
||||
pub inference: ModernInferenceQueueStats,
|
||||
pub legacy_tts: LegacyQueueDetails,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct TtsQueueStats {
|
||||
pub struct LegacyQueueDetails {
|
||||
pub pending_job_count: u64,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct InferenceQueueStats {
|
||||
pub struct ModernInferenceQueueStats {
|
||||
pub total_pending_job_count: u64,
|
||||
|
||||
#[deprecated(note="the frontend uses this field, but we should switch to total_pending_job_count")]
|
||||
pub pending_job_count: u64,
|
||||
|
||||
pub by_queue: ByQueueStats,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ByQueueStats {
|
||||
pub pending_svc_jobs: u64,
|
||||
pub pending_rvc_jobs: u64,
|
||||
//pub pending_face_animation_jobs: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum GetUnifiedQueueStatsError {
|
||||
@@ -75,8 +86,17 @@ pub async fn get_unified_queue_stats_handler(
|
||||
success: true,
|
||||
cache_time: NaiveDateTime::from_timestamp(0, 0),
|
||||
refresh_interval_millis: server_state.flags.frontend_unified_queue_stats_refresh_interval_millis,
|
||||
inference: TtsQueueStats { pending_job_count: 10_000 },
|
||||
legacy_tts: TtsQueueStats { pending_job_count: 10_000 },
|
||||
inference: ModernInferenceQueueStats {
|
||||
total_pending_job_count: 10_000,
|
||||
pending_job_count: 10_000,
|
||||
by_queue: ByQueueStats {
|
||||
pending_svc_jobs: 10_000,
|
||||
pending_rvc_jobs: 10_000,
|
||||
}
|
||||
},
|
||||
legacy_tts: LegacyQueueDetails {
|
||||
pending_job_count: 10_000,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -167,8 +187,17 @@ pub async fn get_unified_queue_stats_handler(
|
||||
success: true,
|
||||
cache_time: stats_result.present_time,
|
||||
refresh_interval_millis: server_state.flags.frontend_pending_inference_refresh_interval_millis,
|
||||
inference: TtsQueueStats { pending_job_count: stats_result.generic_job_count },
|
||||
legacy_tts: TtsQueueStats { pending_job_count: stats_result.legacy_tts_job_count },
|
||||
inference: ModernInferenceQueueStats {
|
||||
total_pending_job_count: stats_result.generic_job_count,
|
||||
pending_job_count: stats_result.generic_job_count,
|
||||
by_queue: ByQueueStats {
|
||||
pending_svc_jobs: 0,
|
||||
pending_rvc_jobs: 0,
|
||||
}
|
||||
},
|
||||
legacy_tts: LegacyQueueDetails {
|
||||
pending_job_count: stats_result.legacy_tts_job_count
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user