Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stash LoadBalancingPolicy on ClusterConfig #733

Closed
Kahbazi opened this issue Feb 10, 2021 · 5 comments
Closed

Stash LoadBalancingPolicy on ClusterConfig #733

Kahbazi opened this issue Feb 10, 2021 · 5 comments
Labels
Type: Idea This issue is a high-level idea for discussion.

Comments

@Kahbazi
Copy link
Collaborator

Kahbazi commented Feb 10, 2021

Currently the ILoadBalancePolicy is get from a dictionary on each request in LoadBalancingMiddleware.

var currentPolicy = _loadBalancingPolicies.GetRequiredServiceById(proxyFeature.ClusterConfig.Options.LoadBalancingPolicy, LoadBalancingPolicies.PowerOfTwoChoices);

Can we stash a ILoadBalancePolicy on ClusterConfig when building a cluster to improve the performance?

@Kahbazi Kahbazi added the Type: Idea This issue is a high-level idea for discussion. label Feb 10, 2021
@Tratcher
Copy link
Member

That's an interesting idea. @MihaZupan @alnikola has the load balancing policy lookup shown up in the CPU profiles at all?

@Kahbazi
Copy link
Collaborator Author

Kahbazi commented Feb 10, 2021

The same thing also could be done for IPassiveHealthCheckPolicy.

var policy = _policies.GetRequiredServiceById(options.Policy);
var cluster = context.GetRequiredRouteConfig().Cluster;
policy.RequestProxied(cluster, proxyFeature.SelectedDestination, context);

@karelz
Copy link
Member

karelz commented Feb 11, 2021

Triage: We should first prove it shows up on profiles to justify the complexity.
Per @MihaZupan dictionary lookups are cheaper in .NET 5 and even more in .NET 6 as well. It didn't show up in @alnikola profiles so far ...

@MihaZupan
Copy link
Member

A few Dictionary improvements I had in mind (looks like they all made it in 5.0):
dotnet/coreclr#27195
dotnet/coreclr#27299
dotnet/runtime#36252

@karelz
Copy link
Member

karelz commented Mar 22, 2021

Triage: Closing - the work in #734 did not bring the expected gains. Not worth it.

@karelz karelz closed this as completed Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Idea This issue is a high-level idea for discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants