Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simple array for AggregateException inner exceptions storage #44787

Merged
merged 4 commits into from
Nov 19, 2020

Conversation

marek-safar
Copy link
Contributor

@marek-safar marek-safar commented Nov 17, 2020

to drop unnecessary wrapping into ReadOnlyCollection. The change also simplified ctor chaining to avoid extra wrapping/casts where it's not needed.

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

// because we're going to put them into a ReadOnlyCollection which simply reuses
// the list passed in to it. We don't want callers subsequently mutating.
Exception[] exceptionsCopy = new Exception[innerExceptions.Count];
_innerExceptions = cloneExceptions ? new Exception[innerExceptions.Length] : innerExceptions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Exception[])innerExceptions.Clone()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better with the cast from object?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, not sure what you mean by that question.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant is Clone version better if it has to generate a cast check?

@stephentoub
Copy link
Member

What is the purpose of this change?

@marek-safar
Copy link
Contributor Author

marek-safar commented Nov 17, 2020

What is the purpose of this change?

@stephentoub remove the unnecessary wrapping and ROS dependency and interfaces casts.

@stephentoub
Copy link
Member

But it still uses ROC:

private ReadOnlyCollection<Exception>? _rocView;

What am i missing?

@marek-safar
Copy link
Contributor Author

It's used from a single property now which is rarely used (and could be avoided if needed). The linker will be able to remove the field by default whereas before it was a dependency from ctor which made it essentially non-trimmable.

@stephentoub
Copy link
Member

which is rarely used

Not really. Most code paths that explicitly catch AggregateException then use InnerExceptions. And even this PR is insufficient I'd expect to be able to ever trim it from corelib, since Task itself relies on InnerExceptions in a way that's unlikely to be trimmable.

If the goal is to enable ROC to be trimmable in most apps, let's make sure this PR actually does that.

@marek-safar
Copy link
Contributor Author

marek-safar commented Nov 17, 2020

since Task itself relies on InnerExceptions in a way that's unlikely to be trimmable.

This didn't show up for wasm but I fixed the calls anyway to make this change more effective.

@marek-safar marek-safar merged commit f2feed9 into dotnet:master Nov 19, 2020
@marek-safar marek-safar deleted the roc branch November 19, 2020 08:23
@ghost ghost locked as resolved and limited conversation to collaborators Dec 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants