[ 
https://issues.apache.org/jira/browse/AVRO-3893?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated AVRO-3893:
---------------------------------
    Labels: c# pull-request-available  (was: c#)

> Significant allocations from unnecessary lambda capture on deserialization 
> path
> -------------------------------------------------------------------------------
>
>                 Key: AVRO-3893
>                 URL: https://issues.apache.org/jira/browse/AVRO-3893
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: csharp
>            Reporter: Jannick Bitsch
>            Priority: Major
>              Labels: c#, pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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:
>  
> {code:java}
> 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));
>         }
>         ....
>  {code}
> It should be a simple improvement to use the value passed to the Func<string, 
> Type> instead. Will open a PR. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to