Skip to content
This repository was archived by the owner on Nov 2, 2018. It is now read-only.

[Design] Reduce DI Allocations #289

Closed
wants to merge 11 commits into from

Conversation

benaadams
Copy link
Contributor

Resolves #288

@dnfclas
Copy link

dnfclas commented Sep 14, 2015

Hi @benaadams, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

Or should it be reinitalised each time?
@@ -19,12 +19,12 @@ internal class ServiceProvider : IServiceProvider, IDisposable
{
private readonly object _sync = new object();

private readonly Func<Type, Func<ServiceProvider, object>> _createServiceAccessor;
private Func<Type, Func<ServiceProvider, object>> _createServiceAccessor;
Copy link
Member

Choose a reason for hiding this comment

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

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In error, has no state


public ServiceScope(ServiceProvider scopedProvider)
{
_scopedProvider = scopedProvider;
}
internal ServiceScope(ServiceProvider scopedProvider, ServiceScopeFactory parentFactory)
Copy link
Member

Choose a reason for hiding this comment

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

Why internal for this? will the public constructor ever be used with these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suppose not, missed it was an internal class

@@ -19,9 +21,19 @@ public IServiceProvider ServiceProvider
get { return _scopedProvider; }
}

internal void Reset()
Copy link
Member

Choose a reason for hiding this comment

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

Why internal here? It would also be helpful to capture your explanation of this in comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what to write... Its a method that is explicitly bonded to the pooling of ServiceScopeFactory so if the class were made public rather than internal for whatever reason the exposed api would be for it to function as a standalone class (which is why I left public constructor in); whereas the "internals" only work as a class pair.

Not hugely fussed on visibility though, can make public

Copy link
Member

Choose a reason for hiding this comment

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

I would leave it internal

@benaadams
Copy link
Contributor Author

Note: still need to implement unit test proposed by @rynowak, lost in outdated diff messages

@benaadams
Copy link
Contributor Author

See aspnet/HttpAbstractions#402 (comment) for details on server run improvements (61.5k rps -> 1.49M rps)

@rynowak
Copy link
Member

rynowak commented Sep 15, 2015

⌚ - just waiting on a unit test for the scenario we discussed

@benaadams
Copy link
Contributor Author

Have the test, just trying to think of the right name XD

@benaadams benaadams changed the title Reduce DI Allocations [Design] Reduce DI Allocations Sep 16, 2015
@halter73
Copy link
Member

👍

@davidfowl davidfowl closed this Sep 22, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants