Repository navigation
CacheView optimizations - #68953
CacheView optimizations#68953
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR simplifies CacheView cache-key computation by removing the static sorted-name cache used to canonicalize comma-separated VaryBy* parameter name lists, and instead re-splitting/re-sorting names per call.
Changes:
- Removed the
ConcurrentDictionary-based cache (and Hot Reload invalidation hook) used for caching sorted vary-by name lists. - Updated
CollectSortedNamesto build and sort the list on demand and return aList<string>for enumeration.
File summaries
| File | Description |
|---|---|
| src/Components/Endpoints/src/CacheView/CacheViewKeyResolver.cs | Removes the static cache for sorted vary-by names and replaces it with per-call parsing/sorting in key computation. |
Review details
Suppressed comments (1)
src/Components/Endpoints/src/CacheView/CacheViewKeyResolver.cs:163
- CollectSortedNames currently calls AsSpan() repeatedly and creates an un-sized List, which can add avoidable overhead now that this runs per ComputeKey invocation. Capturing the span once and pre-sizing the list (typical VaryBy* counts are small) keeps the simplified approach while reducing per-call overhead.
var names = new List<string>();
foreach (var segment in separatedValues.AsSpan().Split(','))
{
var name = separatedValues.AsSpan()[segment].Trim();
if (!name.IsEmpty)
{
names.Add(name.ToString());
}
}
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
javiercn
left a comment
There was a problem hiding this comment.
LGTM, are there tests for this already and didn't change?
|
@javiercn I didn't test caching, as it was only improvement, so none of the tests needed deletion or updating. |
Youssef1313
left a comment
There was a problem hiding this comment.
Should this target release/11.0 instead?
|
@Youssef1313 I will backport it after it merged to main |
|
/ba-g Build insights is hanging |
That's fine. It's also possible to only merge it to release/11.0. There is an automation that will get it later to main. |
|
/backport to release/11.0 |
|
Started backporting to |
Co-authored-by: Daria Tiurina <[email protected]>
CacheView optimizations
Description
In
CacheViewcomponent we use static dictionary that caches results of the sorting of parameters which we use inVaryByparameter optimization. We do not need it and it bring unnecessary complexity for the calculation of CacheKey, because oneVaryByparameter usually have 1 to 3 values and sorting those doesn't require caching.