Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
During investigation of a GC issue in a C# project we discovered that ~10% of allocations could be attributed to an unnecessary lambda capture on a hot-path of Avro deserialization while utilizing a PreresolvingDatumReader.
The capture happens in ObjectCreator.FindType where, instead of using the 'key' parameter passed to the value function, the lambda captures the 'name' method parameter:
private Type FindType(string name) { return typeCacheByName.GetOrAdd(name, (_) => { Type type = null; if (TryGetIListItemTypeName(name, out var itemTypeName)) { return GenericIListType.MakeGenericType(FindType(itemTypeName)); } if (TryGetNullableItemTypeName(name, out itemTypeName)) { return GenericNullableType.MakeGenericType(FindType(itemTypeName)); } ....
It should be a simple improvement to use the value passed to the Func<string, Type> instead. Will open a PR.
Attachments
Issue Links
- links to