Repository navigation
Conversation
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.
Description
After a Lite deployment first uses a model, changing
model.max_concurrencydoes not change that model's actual local concurrency cap. The settings service updates the governor without a restart, and subsequent calls pass the new limit, butlocalLimiterkeeps the channel capacity from its first acquire. Raising 1 to 2 still blocks the second call; lowering 2 to 1 admits a waiter as soon as either old holder releases. Runtime statistics report the new limit even while admission follows the old one.Track the active holders and current limit under the existing limiter mutex, with a notification channel for releases and limit changes. The next acquire carrying an updated limit applies it to the existing pool and wakes waiters. Existing holders keep their release callbacks; after a decrease, new calls wait until active holders fall below the new cap. Existing waiters use the pool's updated limit when they wake rather than restoring their older argument. Preserve cancellation fail-open behavior, per-model isolation and idempotent release.
Type of Change
Related Issue
Found during source review; no separate issue. Searched open/closed issues and PRs for localLimiter, local semaphore, dynamic concurrency, limit update and max_concurrency; no direct duplicate found. The public runtime-settings contract is documented by
SetGlobalLimitandsystemSettingService.applyModelMaxConcurrency.This is independent of #4872: that PR releases a chat stream's held slot on cancellation; this PR changes local slot admission when a configured limit changes. There are no shared files or required merge order, and no changes to the Redis limiter or configuration/API schema.
Testing
Windows/amd64 with CGO enabled and existing portable GCC/G++.
go test -race ./internal/models/limiter -count=10passes on Go 1.26.0. Includes a third regression that checks an existing waiter survives a limit change and retains the updated limit.go test ./internal/models/chat ./internal/models/vlm ./internal/models/limiter -count=1passes on Go 1.27.0.golangci-lint run --new-from-rev=origin/main ./internal/models/limiter/...passes with CI-pinned v2.12.2 on Go 1.26.0 (0 issues); v2.15.0 on Go 1.27.0 also passes.No full-repository or live-provider checks were run. Local limit tests require no external services; existing package tests use miniredis for Redis behavior.
Checklist
git diff --check origin/main...HEADpassesPrepared with AI assistance.