Skip to content

Conversation

petrroll
Copy link
Contributor

@petrroll petrroll commented Jul 8, 2025

Fixes Issue #109446

Description

Special cases most common (IMHO by super vast majority) case of IOtionsMonitor for default options name, i.e. "". Most importantly changes .CurrentValue access from concurentdictionary read to a field access.

Customer Impact

Small perf.

Regression

No.

Testing

I'll add tests if it's deamed feasible and worthy of being merged.

Risk

Substentially increases complexity of originally super simple class. The complecity is still very limited and IMHO perfectly managable but it went from super duper simple to somewhat simple.

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 8, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 8, 2025
@petrroll petrroll force-pushed the u/petrhouska/improve-default-case-of-options-cache branch from 05b94ab to d523140 Compare July 8, 2025 18:02
@petrroll petrroll closed this Jul 8, 2025
@petrroll petrroll force-pushed the u/petrhouska/improve-default-case-of-options-cache branch from d523140 to d4c1aa9 Compare July 8, 2025 18:03
@petrroll petrroll reopened this Jul 8, 2025
@petrroll petrroll force-pushed the u/petrhouska/improve-default-case-of-options-cache branch 3 times, most recently from 4e9500d to f4f3849 Compare July 9, 2025 07:04
@petrroll
Copy link
Contributor Author

petrroll commented Jul 9, 2025

Method Mean Error StdDev Allocated
Baseline 10.0452 ns 0.2823 ns 0.4944 ns -
Better 0.6969 ns 0.0287 ns 0.0254 ns -
    [Benchmark]
    public string Baseline()
    {
        var opt = optionsCache.GetOrAdd(null, () => new MyOptions { Name = "Default", Value = 42 });
        return opt.Name;
    }

    [Benchmark]
    public string Better()
    {
        var opt = optionsCacheBetter.GetOrAdd(null, () => new MyOptions { Name = "Default", Value = 42 });
        return opt.Name;
    }

https://pastebin.com/Vf5XRC8K

@huoyaoyuan huoyaoyuan added area-Extensions-Options and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jul 9, 2025
Copy link
Contributor

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

@petrroll petrroll force-pushed the u/petrhouska/improve-default-case-of-options-cache branch from f4f3849 to 9f800da Compare July 9, 2025 10:11
Copy link
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@petrroll
Copy link
Contributor Author

petrroll commented Aug 8, 2025

Could it be reopened @huoyaoyuan ? I'd still be fully up for merging it :)

@tarekgh
Copy link
Member

tarekgh commented Aug 8, 2025

The bar for .NET 10 is now quite high—similar to the servicing bar. Let’s wait until the main branch opens for the next release, and then we can reopen and merge. This should happen in a few weeks from now. Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2025
@tarekgh tarekgh reopened this Sep 18, 2025
@tarekgh tarekgh added this to the 11.0.0 milestone Sep 18, 2025
@tarekgh tarekgh self-assigned this Sep 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Extensions-Options community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants