[Perf] #1550 - Turn ModelMetadataProvider into a singleton
The modelmetadataprovider does significant reflection caching, which shows up as a hotspot. It's only of our most commonly used services, so not only do a TON of instances get created, they are very heavy-weight because of the two ConcurrentDictionary instances they have.
This commit is contained in:
parent
e94cec51fa
commit
3c380bc38e
|
|
@ -79,7 +79,9 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
// Dataflow - ModelBinding, Validation and Formatting
|
||||
|
||||
yield return describe.Transient<IModelMetadataProvider, DataAnnotationsModelMetadataProvider>();
|
||||
// The DataAnnotationsModelMetadataProvider does significant caching of reflection/attributes
|
||||
// and thus needs to be singleton.
|
||||
yield return describe.Singleton<IModelMetadataProvider, DataAnnotationsModelMetadataProvider>();
|
||||
|
||||
yield return describe.Transient<IInputFormatterSelector, DefaultInputFormatterSelector>();
|
||||
yield return describe.Scoped<IInputFormattersProvider, DefaultInputFormattersProvider>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue