Skip to content

Test inlining changes for CredentialCache perf#124614

Draft
MihaZupan wants to merge 1 commit intodotnet:mainfrom
MihaZupan:uri-credentialcache-perf
Draft

Test inlining changes for CredentialCache perf#124614
MihaZupan wants to merge 1 commit intodotnet:mainfrom
MihaZupan:uri-credentialcache-perf

Conversation

@MihaZupan
Copy link
Member

@MihaZupan MihaZupan added this to the 11.0.0 milestone Feb 19, 2026
@MihaZupan MihaZupan self-assigned this Feb 19, 2026
Copilot AI review requested due to automatic review settings February 19, 2026 19:22
@MihaZupan MihaZupan added the NO-REVIEW Experimental/testing PR, do NOT review it label Feb 19, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

@MihaZupan
Copy link
Member Author

@EgorBot -profiler -linux_azure_arm

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Net;

public class CredentialCacheTests
{
    private const string UriPrefix = "http://name";
    private const string AuthenticationType = "authType";

    private static readonly NetworkCredential s_credential = new();
    private static readonly CredentialCache _cache = CreateCredentialCache(10);

    private readonly string _uriString = "http://name5";
    private Uri? _reusedUri;

    [Benchmark]
    public NetworkCredential GetCredential_Uri() => _cache.GetCredential(new Uri(_uriString), AuthenticationType);

    private static CredentialCache CreateCredentialCache(int uriCount)
    {
        var cc = new CredentialCache();

        for (int i = 0; i < uriCount; i++)
        {
            Uri uri = new Uri(UriPrefix + i.ToString());
            cc.Add(uri, AuthenticationType, s_credential);
        }

        return cc;
    }
}

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds a [MethodImpl(MethodImplOptions.NoInlining)] attribute to the IsPrefix method in CredentialCacheKey to investigate potential performance improvements for the GetCredential_Uri benchmark, which showed a 35% regression (309ns → 418ns) according to issue #124520. The change prevents the JIT compiler from inlining this method into its caller.

Changes:

  • Added NoInlining attribute to the IsPrefix method to test if preventing inlining resolves the performance regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Meta NO-REVIEW Experimental/testing PR, do NOT review it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments