Repository navigation
perf(auth): shard non-promoting auth cache lookups - #284
Open
perfloop[bot] wants to merge 1 commit into
Open
perfloop[bot] wants to merge 1 commit into
perfloop[bot] wants to merge 1 commit into
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryThe PR splits signing keys and bucket grants across 64 bounded caches. Reads use
Reviews (1) · Last reviewed commit: "perf(auth): shard cache-hit authenticati..." · Reviewed by Greptile |
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.
Every transparent Range cache hit validates the client's SigV4 request before reading the cache. This change parses auth once, looks up the exact learned signing key, performs the existing HMAC comparison, and checks the bucket grant without promoting the key or grant on a hit. The derived-key and authorization stores use bounded expirable-LRU shards with non-promoting Peek reads. Existing TTLs and synchronous 403 revocation remain in place; missing or expired entries still follow the upstream validation path.
The lookup change applies when TAG forwards transparently: default transparent mode and tiered mode with a Tigris endpoint. Signing mode keeps its credential-store path. The total limits remain 100K signing keys and 1M grants. Capacity is split across shards, so a full shard can evict while another has room; under a skewed key distribution this can cause an earlier upstream check, but never a local authorization on a miss.
The existing
handlers/block_cache_certified_range_benchmark_test.gobenchmark (BenchmarkHandleGetObjectCertifiedRange/local/blocks-2) exercises the production validator and auth stores on a routed block-range cache hit. Two local 2-second paired runs measuredns/opof 1,882,096 and 1,878,159 before versus 1,834,848 and 1,831,215 after; averagettfb-ns/opwas 798,471 and 789,110 before versus 765,265 and 763,168 after. It is a sequential block-mode workload, not the high-fan-out whole-object Range workload.The 64-worker replay harness at
handlers/auth_cache_range_benchmark_test.gois temporary measurement support and is not included in this pull request. It prewarms learned keys and an embedded cache, then sends 64 concurrent valid-SigV4 requests with one identity per worker for 64KiB ranges from 100KiB whole-cached objects. The in-process router and production validator are measured for a fixed 400,000 requests per invocation, with 64 workers scheduled over four Go Ps; the fake upstream fails if a timed request misses. Setup verifies the exact range CRC, and each timed response checks 206/HIT, ETag, Content-Range, Content-Length, and byte count. The reported p99 is handler completion, not socket or client latency. A separate mutex profile was collected for the baseline and sharded lookup path; the profile files are local diagnostics and are not included in this pull request. Production request mix, frequency, and identity distribution remain unmeasured.requests/sp99-ns/opns/opEach workload ran 9 paired runs.
Testing
make buildandmake lint-cipassed. The auth, proxy, and handler unit and race packages passed. Focused integration tests cover per-bucket grants, 403 revocation, write-only non-grants, presigned fallback, and multipart replay authorization.Generated by Perfloop.
Note
Medium Risk
Changes the local SigV4 validation and authorization-cache hot path; sharded eviction can increase upstream checks under skew but should not grant cache access on misses.
Overview
Introduces a sharded, read-mostly TTL cache (
readMostlyTTLTable) for transparent-proxy local auth: 64 expirable-LRU shards withPeekon reads so hot Range/cache hits do not promote entries or contend on a single LRU lock.AuthzCacheandDerivedKeyStoresigning-key storage now use this table (same global caps: 1M grants, 100K keys); grants still useStore/Remove, TTLs and 403 revocation unchanged.validateLocallycallsRequestValidator.Validateonce (parse + exact key lookup + HMAC) instead of separate parse /HasKey/ValidateRequest, with the same missing-auth, parse-error, unknown-key, and signature-mismatch fallbacks to upstream; bucket checks use the validated access key.Adds unit tests for non-promoting reads, bounded total capacity across shards, and concurrent read/write.
Reviewed by Cursor Bugbot for commit 6d558e5. Bugbot is set up for automated code reviews on this repo. Configure here.