[
https://issues.apache.org/jira/browse/AVRO-3893?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jannick Bitsch updated AVRO-3893:
---------------------------------
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:
{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.
was:
During investigation of a GC issue of a C# project we discovered that ~10%
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.
> 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#
>
> 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)