Switching the TypeConverterCache from a Dictionary to a ConcurrentDictionary accidentally re-introduced a Func<T> allocation on every .GetOrAdd() call.
Remove that allocation in the hot path by calling LookupTypeConverter statically. This saves ~5MB of allocations in the serialization benchmark.
Switching the
TypeConverterCache
from aDictionary
to aConcurrentDictionary
accidentally re-introduced aFunc<T>
allocation on every.GetOrAdd()
call.Remove that allocation in the hot path by calling
LookupTypeConverter
statically. This saves ~5MB of allocations in the serialization benchmark.Before
After