Skip to content

Load runs list job submissions without sorting all of them - #4472

Merged
r4victor merged 3 commits into
masterfrom
issue_4468_runs_list_latest_job_submissions
Nov 6, 2026
Merged

r4victor merged 3 commits into
masterfrom
issue_4468_runs_list_latest_job_submissions

Conversation

@r4victor

@r4victor r4victor commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

On dstack Sky, slow /api/runs/list requests spend 0.6-1.8 s loading jobs, because the server sorts every submission of the listed runs with all its columns to keep the latest ones, and does it twice. Fixes #4468.

  • Load job submissions with one query that finds each job's latest submission numbers and fetches only the submissions within job_submissions_limit of the latest one, plus the latest submission with a termination reason; a job whose submission numbers have gaps from deleted no-capacity submissions can get fewer than job_submissions_limit submissions, which the API already allows.
  • Replace ix_jobs_run_id with an index on (run_id, replica_num, job_num, submission_num), so each job's latest submissions are an index lookup; without it, SQLite, which has no hash join, is slower than before for runs with many replicas.
  • Make job_submissions_limit required in the runs list service and drop the unreachable full-history branch, since the router always passes a limit.

In a benchmark with 100 runs per page, loading jobs for runs with 200 submissions each goes from 103 ms to 16 ms on Postgres, and for runs with 50 replicas × 20 submissions from 828 ms to 167 ms on SQLite.

@r4victor
r4victor merged commit 2adbfd6 into master Nov 6, 2026
26 checks passed
@r4victor
r4victor deleted the issue_4468_runs_list_latest_job_submissions branch November 6, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: /api/runs/list sorts every job submission of the listed runs

1 participant