Hi all,

We ran into a performance issue in the C# ObjectCreator and would appreciate 
feedback on it and on a possible fix.

ObjectCreator.FindType resolves generated classes by enumerating all types of 
all loaded assemblies for every schema name not found in the entry assembly. In 
large .NET applications this makes the first deserialization of a schema take 
seconds: resolving 50 named types takes 6 s and allocates 6 GB with 250k loaded 
types (in a benchmark). In our case, one of our Kafka consumers spends about 5 
s on the first message after every restart.

I opened AVRO-4357 (https://issues.apache.org/jira/browse/AVRO-4357) and a PR 
with one possible approach: https://github.com/apache/avro/pull/4030
It looks up namespaced names directly with Assembly.GetType per loaded assembly 
and keeps the existing enumeration as fallback, so it resolves the same types 
as before. That brings the case above down to 4.4 ms. Tests and a 
BenchmarkDotNet benchmark are included.

I'd be glad to hear whether this is the right direction, or whether you'd 
prefer to address it differently.

Thanks,
Gerald

Reply via email to