question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exceptions in new version

See original GitHub issue

Hi @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:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
promontiscommented, Oct 24, 2019

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

1reaction
dstelljescommented, Oct 24, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found