Repository navigation
Conversation
kozistr
marked this pull request as ready for review
October 1, 2026 14:15
[High impact] The PR appears safe to merge; no new actionable issues were found. SummaryFixes rejected-request accounting and protects instance queues during concurrent lookups and removal.
No new actionable issues were found. The code and build setup were reviewed without running the regression tests. DiagramsequenceDiagram
participant Waiter as Slot checker
participant Limiter as Rate limiter
participant Queue as Instance queue
participant Removal as Instance removal
Waiter->>Limiter: Check for a consumer
Limiter->>Limiter: Copy shared queue ownership under locks
Limiter->>Queue: Wait after releasing registry locks
Removal->>Queue: Close queue
Queue-->>Waiter: Wake and return false
Removal->>Limiter: Erase queue entry
Reviews (7) · Last reviewed commit: "Merge branch 'main' into fix/batcher-acc..." · Reviewed by Greptile |
kozistr
marked this pull request as draft
October 1, 2026 15:23
kozistr
marked this pull request as ready for review
October 1, 2026 15:41
Contributor
|
CI-Pipeline-ID: 75939693 |
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.
Context
DynamicBatchScheduler::Enqueue, a full-queue rejection leavesqueued_batch_size_inflated because the scheduler increments it before admission succeeds. Later admissions can trigger unnecessary wake-ups against the preferred batch-size threshold.RateLimiter, live instance changes erasespecific_queues_while other threads read capacity or look up queues. ThreadSanitizer reproduced map reads racing with node deallocation. Removal can destroy a queue that a blocking slot check still uses.Honestly, i'm very new here and not very familar with C++, so i used Codex to help me understand and reproduce the bug. So, please fell free to let me know if there are any issues with the coding style or changes!
Solution
queued_batch_size_after successful admission.PayloadQueue::mu_for instance-map access and removal. Move consumer-count updates into the existing enqueue/dequeue critical sections, preserving accounting for targeted and generic payloads. Run payload-release and final dequeue callbacks outside that mutex.Other things
I compared median throughput across three runs per build, with 10,000 measured requests per case and 32 HTTP clients:
Throughput differences are smaller than the variation across runs. These measurements cover CPU HTTP/Python workloads; I have not tested GPU workloads.
Reproduction and environment
Compare base commit
3af839d613da6995051f9bcfab00efe2eac87d4cwith this branch. I usednvcr.io/nvidia/tritonserver:26.09-py3on Docker Desktop/WSL2, Linux x86_64, CPU, GCC 13.3, CMake 3.31.10, and GCC ThreadSanitizer. I built both libraries with the same optimized settings and dependencies, then loaded the fixed library into Triton viaLD_LIBRARY_PATH. The local build required the Protobuf compatibility alias-Dalways_print_fields_with_no_presence=always_print_primitive_fields.Build and run the committed regression harness:
The accounting test fills a two-request queue with batches of eight and one, rejects seven admissions, drains the batch of eight, and admits another request. A batching callback checks that the later admission leaves the batcher waiting below the preferred size of eight. Restoring the old increment triggers an extra wake-up and fails the assertion. The test drains both remaining requests before scheduler teardown, including after that assertion fails.
For the map races, configure a separate build with
-DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer"and-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread -no-pie", then run the same commands. The capacity and lookup cases read queues while another thread registers and removes two instances for 2,000 iterations. Removing the erase lock triggers sanitizer reports. The instance/model-removal cases block a slot check and require removal to release it with a false result.I instrumented the harness and its core sources. Container address randomization caused some sanitizer startup failures; I retried those starts and treated sanitizer reports or test failures as failures.