Repository navigation
optimize(logging): make logging asynchronous to prevent slow output from blocking requests - #5248
Open
caikun-pjlab wants to merge 1 commit into
Open
caikun-pjlab wants to merge 1 commit into
caikun-pjlab wants to merge 1 commit into
Conversation
Use bounded 8192-entry queues and daemon writers for LMDeploy and Uvicorn logs. Snapshot formatted text before enqueueing, silently drop records on saturation or output failure, and avoid waiting for blocked output during shutdown. Replace diagnostic print calls with logger calls while preserving interactive and report output. Cover mutable arguments, lock contention, fork, blocked output, shutdown, and API/monitoring health responses. Validation: 55 focused tests passed; pre-commit checks passed.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Synchronous logging can stall request processing when stdout is redirected to slow or overloaded storage, such as GPFS. Uvicorn emits access logs before sending response headers, so a blocked log write can significantly delay
/health, even when the model is healthy.This also affects the dedicated monitoring server: its separate event loop still uses the same logging infrastructure.
Changes
printcalls with logger calls while preserving interactive, report, and example output.Existing logger formatting is preserved.
Benefits
Performance and validation
Validated with a deployed GLM-5.3-Flash service using DP=8 and EP=8, plus its router.
To simulate blocked stdout writes, the test paused consumption of a 4096-byte stdout pipe. Kernel
pipe_writewaits confirmed that logging was actually blocked. This simulates output backpressure; it is not a GPFS benchmark.For the dedicated monitoring endpoint,
:9100/health, each phase used 9600 requests with 24 concurrent clients:During approximately 17.6 seconds of blocked output:
A separate test of the regular API
/healthendpoint also completed 9600/9600 requests during blocked output, with 8.08 ms P99 latency.Trade-offs
Queued records may be lost on overflow, output failure, or process exit, including error-level records. Formatting still runs on the calling thread; the asynchronous boundary covers output I/O. Native and third-party logging that bypasses these handlers is outside this change’s scope.