Added capability to cache filter and assignment parameters. #180
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 PR adds a filter parameters binder interface to allow feature manager to cache bound feature filter and feature variant assignment parameters for performance optimization.
Why
Feature filters are given filter parameters in the form of
IConfiguration
that instruct them how to perform feature evaluation. Often these parameters are bound to a strongly typed settings object before use. Observed cost of bindingIConfiguration
to perform feature evaluation is high. By caching the result of the binding, a noticeable performance increase can be achieved. This PR gives Implementers of IFeatureFilter and IFeatureVariantAssigner the option to take cache these settings with the help of the feature management system. This is possible through theIFilterParametersBinder
andIAssignmentParametersBinder
interfaces.Example Usage
Breaking Change
This PR introduces a possible breaking change for custom feature definition providers that implement
IFeatureFlagDefinitionProvider
orIDynamicFeatureDefinitionProvider
. To ensure that any filters that implementIFilterParametersBinder
see updates to feature filter parameters or feature variant assignment parameters when they are changed, definition providers should ensure a new object reference is used for the parameters in the feature definition. Otherwise, the filters will continue to use the same settings from the cache.Perf
Rough performance assessment showed improvements of ~100 times at least for complex settings objects.