You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: async cache update and batch cache check to reduce lock contention
Two optimizations to reduce lock contention in the Check endpoint:
1. Async cache update: UpdateCacheWithChecks now runs in a background
goroutine by default (configurable via AUTHZCACHE_ASYNC_CACHE_UPDATE),
so the write lock doesn't block concurrent readers.
2. Batch cache check: New CheckRelations method acquires the read lock
once for the entire batch instead of per-relation, eliminating N-1
redundant lock acquire/release cycles.
Combined, these reduce p50 latency by ~54% for 5000-relation checks
under concurrent load.
Resolvesdescope/etc#14193
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
// iterate over relations and check cache, if not found, check later in sdk
108
-
varcachedChecks []*descope.FGACheck
109
-
vartoCheckViaSDK []*descope.FGARelation
110
-
varindexToCachedChecksmap[int]*descope.FGACheck=make(map[int]*descope.FGACheck, len(relations)) // map "relations index" -> check, used to retain same order of relations in checks response
111
-
fori, r:=rangerelations {
112
-
ifallowed, direct, ok:=projectCache.CheckRelation(ctx, r); ok {
0 commit comments