Skip to content

IOptionsMonitor.Current always go though ConcurrentDictionary getter - perf? #109446

Open
@petrroll

Description

@petrroll

OptionsMonitor<T>.Current is not a field, it invokes a get on ConcurrentDictionary. In some codebases this can be used a lot. Sure, caching the current value is possible but the API surface doesn't make it obvious that it should be done.

I understand it's for simplicity allowing the same codepath to be used for named Config values as well as the default named string.Empty (which this property getter accesses) but it might be worth it to special case for the most common scenario and cache current value in a normal field so that access is essentially free (and inlinable and all that).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions