Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical null-value caching bug causes first-time plain-member lookups to throw instead of returning null, leaving the miss-caching behavior incorrect and its test failing.
1 open issue
What changed in this PR
This PR improves query-expansion performance by caching external [ExpressiveFor] lookups, including misses, and replacing repeated assembly-count scans with generation-based invalidation.
Changes:
- Added external-expression caching and assembly-load invalidation.
- Updated polymorphic plan caching to use the resolver’s registry generation.
- Added cache behavior tests and a benchmark covering plain-member lookups.
| File | Description |
|---|---|
| tests/ExpressiveSharp.Tests/Services/ExpressiveResolverExternalCacheTests.cs | Adds tests for external-expression hit and miss caching, including cache invalidation behavior. |
| src/ExpressiveSharp/Services/ExpressiveResolver.cs | Adds external lookup caching, registry-generation tracking, and incremental assembly scanning. |
| src/ExpressiveSharp/Services/ExpressiveReplacer.cs | Updates polymorphic plan invalidation to use the resolver’s registry generation. |
| benchmarks/ExpressiveSharp.Benchmarks/ExpressionReplacerBenchmarks.cs | Adds a benchmark for expression replacement involving plain-member accesses. |
Review effort: Lite
Comment on lines
+163
to
+175
| if (_externalExpressionCache.TryGetValue(memberInfo, out var cached)) | ||
| return cached; | ||
|
|
||
| var generation = Volatile.Read(ref _registryGeneration); | ||
| var found = FindExternalExpressionCore(memberInfo); | ||
|
|
||
| // A scan that completed meanwhile may have added a registry this lookup did not see. | ||
| if (generation == Volatile.Read(ref _registryGeneration)) | ||
| { | ||
| _externalExpressionCache.TryAdd(memberInfo, found); | ||
| if (generation != Volatile.Read(ref _registryGeneration)) | ||
| _externalExpressionCache.TryRemove(memberInfo, out _); | ||
| } |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This branch has not been deployed
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.

Fixes #113