Exceptions in new version
See original GitHub issueHi @dstelljes!
We see a big performance degrade in creating the schema’s when switches to master (I think this is 3.0). I think this is because of the many exceptions being thrown in code like:
foreach (var @case in Cases)
{
try
{
return @case.Read(element, cache, scope);
}
catch (UnknownSchemaException exception)
{
exceptions.Add(exception);
}
}
throw new AggregateException($"No schema reader case matched {element.ToString()}", exceptions);
Such code is located in JsonSchemaReader
, TypeResolver
, BinarySerializerBuilder
.
This is especially performance heavy when the type/schema is located at the end of the array.
For this POCO…
public class Foo
{
public string Bar { get; set; }
public DateTime Date { get; set; }
}
… I’m currently getting 391 exceptions. All handled, but it takes a long time.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Is changing the exception a method throws a breaking ...
I have a library that I am distributing on maven in the new version I will be changing the exceptions some methods are...
Read more >Built-in Exceptions — Python 3.11.4 documentation
The built-in exception classes can be subclassed to define new exceptions; programmers are encouraged to derive new exceptions from the Exception class or...
Read more >Best Practices for exceptions - .NET
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >Manage exceptions with the debugger in Visual Studio
To add conditional exceptions: Choose the Edit conditions button in the Exception Settings window, or right-click the exception and choose Edit ...
Read more >Working with Java SE 7 Exception Changes
Learn how to take advantage of improved exception handling, one of many useful small language changes found in Project Coin, in Java SE...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Cool! I’ll finish the PR tomorrow probably… if you can build a prerelease, we can just reference the nuget package and everything should work a lot faster!
Thanks for helping out 🤗 Closing
Also very slow for me when referencing source (a project reference to Chr.Avro.Confluent.csproj). When referencing it normally (a package reference to the NuGet release), the debugger doesn’t pick up any of the internal exceptions and the application runs much faster.
It’d definitely be possible to implement the case pattern without relying on exceptions, but it would be a significant amount of work and a breaking change for custom cases. Since this doesn’t affect project debugging unless a developer is referencing a local clone of Chr.Avro, I’m not sure it’s worth it.
A workaround may be to use
[DebuggerHidden]
or one of the other System.Diagnostics attributes.