cache/disk: replace fixed Contains worker pool with semaphore#2
Open
ajwerner wants to merge 2 commits into
Open
cache/disk: replace fixed Contains worker pool with semaphore#2ajwerner wants to merge 2 commits into
ajwerner wants to merge 2 commits into
Conversation
WithProxyBackend spawned 512 permanent containsWorker goroutines at startup to serve proxy Contains lookups for FindMissingBlobs. In deployments where the proxy is rarely exercised, that is 512 idle goroutines for the life of the process — in our fleet, two-thirds of the embedding agent's entire goroutine count. Bound the concurrency with a weighted semaphore (same 512 limit) and spawn one goroutine per check instead. Goroutine spawn cost is noise next to a proxy HEAD request, so throughput is unchanged, and the process carries zero pool goroutines at rest. This also makes admission context-aware: the old bare channel send could park a producer indefinitely with no way to be interrupted by cancellation, while semaphore.Acquire(ctx, 1) returns as soon as the request or fail-fast context is cancelled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
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.
WithProxyBackend spawned 512 permanent containsWorker goroutines at startup to serve proxy Contains lookups for FindMissingBlobs. In deployments where the proxy is rarely exercised, that is 512 idle goroutines for the life of the process — in our fleet, two-thirds of the embedding agent's entire goroutine count.
Bound the concurrency with a weighted semaphore (same 512 limit) and spawn one goroutine per check instead. Goroutine spawn cost is noise next to a proxy HEAD request, so throughput is unchanged, and the process carries zero pool goroutines at rest. This also makes admission context-aware: the old bare channel send could park a producer indefinitely with no way to be interrupted by cancellation, while semaphore.Acquire(ctx, 1) returns as soon as the request or fail-fast context is cancelled.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled. (Staging)Need help on this PR? Tag
/codesmithwith what you need. Autofix is enabled.