Optimize middleware/proxy per-request hot path without behavior changes#1014
Draft
Copilot wants to merge 3 commits into
Draft
Optimize middleware/proxy per-request hot path without behavior changes#1014Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/projectcapsule/capsule-proxy/sessions/2f8293ae-ba3a-459c-aa67-4cf17337115e Co-authored-by: oliverbaehler <26610571+oliverbaehler@users.noreply.github.com>
Agent-Logs-Url: https://github.com/projectcapsule/capsule-proxy/sessions/2f8293ae-ba3a-459c-aa67-4cf17337115e Co-authored-by: oliverbaehler <26610571+oliverbaehler@users.noreply.github.com>
Agent-Logs-Url: https://github.com/projectcapsule/capsule-proxy/sessions/2f8293ae-ba3a-459c-aa67-4cf17337115e Co-authored-by: oliverbaehler <26610571+oliverbaehler@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
oliverbaehler
April 16, 2026 12:28
View session
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1014 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 1 1
Lines 200 200
=====================================
Misses 200 200 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This pull request has been marked as stale because it has been inactive for more than 30 days. Please update this pull request or it will be automatically closed in 7 days. |
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.
This proxy sits on the Kubernetes API request path, so avoidable per-request work in middleware and request handling directly impacts latency/throughput. This change reduces repeated auth parsing and hot-path allocations while preserving existing behavior.
Request-scoped auth resolution cache
ResolveUserAndGroups) to compute user/groups once per request and reuse across middleware/handlers.NewHTTP(...).GetUserAndGroups()calls in:internal/webserver/webserver.gointernal/webserver/middleware/user_in_group.go******** parsing hot-path improvements**
MustCompile).ReplaceAll("Bearer ", "")toTrimPrefix("Bearer ").Proxy handler allocation/recompute reductions
ResponseRecorder.Result()once and closed body once.selector.String()once and reused.BearerToken()once and reused; removed repeated formatting overhead.Example (new request-scoped resolver usage):