Skip to content

Add scheduler prefill queue wait breakdown#28470

Open
RitwijParmar wants to merge 1 commit into
sgl-project:mainfrom
RitwijParmar:codex/prefill-queue-breakdown
Open

Add scheduler prefill queue wait breakdown#28470
RitwijParmar wants to merge 1 commit into
sgl-project:mainfrom
RitwijParmar:codex/prefill-queue-breakdown

Conversation

@RitwijParmar

@RitwijParmar RitwijParmar commented Jun 17, 2026

Copy link
Copy Markdown

Motivation

Follow-up for #28047.

SGLang currently records total scheduler queue time, but that does not show whether high TTFT came from backlog before a request was considered or from budget pressure after the scheduler first tried to admit it.

This PR adds the missing scheduler-side split mentioned in the issue thread.

Modifications

  • Add first_prefill_attempt_time to scheduler request time stats.
  • Stamp it when PrefillAdder first considers a request.
  • Split prefill queue time into prefill_queue_idle and prefill_budget_wait stages.
  • Export the split through per-stage metrics, request traces, duration logs, and output metadata.
  • Reset the first-attempt timestamp on retract and prefill retry resets.
  • Add unit coverage for the split math, serialization, and retry reset behavior.
  • Document the new metric and trace stages under docs_new/.

This does not duplicate the pre-scheduler timing work in #25933. It sits inside scheduler admission. It also does not change HiCache tier counters from #26976.

Accuracy Tests

Not applicable. This only adds timing instrumentation and metadata.

Speed Tests and Profiling

Not applicable. The hot path addition is one guarded timestamp write when a queued request is first considered, plus derived metrics when the request enters forward.

Checklist

  • Add unit tests according to the contribution guide.
  • Update documentation according to the contribution guide.
  • Follow the SGLang code style guidance.
  • Format your code according to pre-commit.
  • Provide accuracy and speed benchmark results.

Local checks run:

  • /Users/ritwij/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3 -m compileall -q python/sglang/srt/observability/req_time_stats.py python/sglang/srt/managers/schedule_policy.py test/registered/unit/observability/test_req_time_stats.py test/registered/unit/managers/test_prefill_adder.py
  • uvx ruff check --extend-ignore E402 python/sglang/srt/observability/req_time_stats.py python/sglang/srt/managers/schedule_policy.py test/registered/unit/observability/test_req_time_stats.py test/registered/unit/managers/test_prefill_adder.py
  • git diff --check

I could not run pytest locally because this checkout is not installed with SGLang dependencies in the current environment. System Python missed pybase64, and the bundled Python does not have pytest. I did run a lightweight stubbed check of the new SchedulerReqTimeStats math and metric calls.


CI States

Latest PR Test (Base): ❌ Run #27657056151
Latest PR Test (Extra): ❌ Run #27657056150

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jun 17, 2026
@RitwijParmar
RitwijParmar force-pushed the codex/prefill-queue-breakdown branch from fc5608c to 240fde4 Compare June 17, 2026 00:19
@RitwijParmar
RitwijParmar force-pushed the codex/prefill-queue-breakdown branch from 240fde4 to 6f6ecab Compare June 17, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant