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

feat: introduce resolve-request abstraction #1188

Conversation

alsami
Copy link
Member

@alsami alsami commented Aug 11, 2020

related to #1164

@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #1188 into develop will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1188      +/-   ##
===========================================
+ Coverage    80.23%   80.25%   +0.02%     
===========================================
  Files          187      187              
  Lines         4371     4371              
  Branches       947      947              
===========================================
+ Hits          3507     3508       +1     
  Misses         414      414              
+ Partials       450      449       -1     
Impacted Files Coverage Δ
src/Autofac/Builder/BuildCallbackManager.cs 100.00% <100.00%> (ø)
src/Autofac/Builder/StartableManager.cs 100.00% <100.00%> (ø)
.../Core/Activators/Reflection/AutowiringParameter.cs 75.00% <100.00%> (ø)
src/Autofac/Core/ImplicitRegistrationSource.cs 86.48% <100.00%> (ø)
src/Autofac/DefaultResolveRequest.cs 100.00% <100.00%> (ø)
...atures/Collections/CollectionRegistrationSource.cs 95.71% <100.00%> (ø)
...Autofac/Features/Decorators/DecoratorMiddleware.cs 90.47% <100.00%> (ø)
...ac/Features/GeneratedFactories/FactoryGenerator.cs 95.55% <100.00%> (ø)
...Dependencies/LazyWithMetadataRegistrationSource.cs 86.11% <100.00%> (ø)
...htAdapters/LightweightAdapterRegistrationSource.cs 82.75% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0c74e68...740d17b. Read the comment docs.

@alsami
Copy link
Member Author

alsami commented Aug 11, 2020

@autofac-bot benchmark DeepGraphResolveBenchmark

@alsami alsami changed the title feat: introduce resolve-request interface feat: introduce resolve-request abstraction Aug 11, 2020
@autofac-bot
Copy link

autofac-bot bot commented Aug 11, 2020

DeepGraphResolveBenchmark

Target: develop

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 18.18 us 0.130 us 0.122 us 0.4883 - - 16.91 KB

Source: feat/introduce_abstraction_for_resolve_request

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 18.97 us 0.093 us 0.083 us 0.4883 - - 16.91 KB

@alsami
Copy link
Member Author

alsami commented Aug 11, 2020

@autofac-bot benchmark DeepGraphResolveBenchmark

@autofac-bot
Copy link

autofac-bot bot commented Aug 11, 2020

DeepGraphResolveBenchmark

Target: develop

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 18.27 us 0.063 us 0.059 us 0.4883 - - 16.91 KB

Source: feat/introduce_abstraction_for_resolve_request

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 18.77 us 0.093 us 0.087 us 0.4883 - - 16.91 KB

@alsami
Copy link
Member Author

alsami commented Aug 11, 2020

@autofac-bot benchmark DeepGraphResolveBenchmark

@autofac-bot
Copy link

autofac-bot bot commented Aug 11, 2020

DeepGraphResolveBenchmark

Target: develop

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 17.30 us 0.085 us 0.080 us 0.4883 - - 16.91 KB

Source: feat/introduce_abstraction_for_resolve_request

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 18.17 us 0.060 us 0.056 us 0.4883 - - 16.91 KB

@alsami
Copy link
Member Author

alsami commented Aug 11, 2020

@autofac-bot benchmark DeepGraphResolveBenchmark

@autofac-bot
Copy link

autofac-bot bot commented Aug 11, 2020

DeepGraphResolveBenchmark

Target: develop

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 17.96 us 0.072 us 0.064 us 0.4883 - - 16.91 KB

Source: feat/introduce_abstraction_for_resolve_request

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 18.71 us 0.322 us 0.301 us 0.4883 - - 16.91 KB

@alsami
Copy link
Member Author

alsami commented Aug 11, 2020

@tillig @alistairjevans basically ready for review.

I ran the benchmarks initially using the bot but the differences were too big comparing develop and PR branch.

I did that for the first commit (twice), which introduced an interface. For the second commit as well, which kind of uses the same principle that we have introduced for ResolveRequestContext. Then I decided to run them manually again, which seems to bring better results but still, does make a difference.

develop:

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 17.91 us 0.351 us 0.329 us 0.4883 - - 16.91 KB

PR branch:

Method Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
Resolve 18.04 us 0.114 us 0.107 us 0.4883 - - 16.91 KB

Any thought's on that? Not sure if I should try the interfaces again now. Also, does a difference of 0.15 us make a big difference? 🤔

@alistairjevans
Copy link
Member

What is the motivation behind making ResolveRequest an interface / abstract class?

I ask because it is a very small type, it can be relatively easily mocked (especially now), and it is very well established as a type you can instantiate and do stuff with. It's going to introduce a lot of extra breaking change.

Might I propose that we have a go updating the unit tests with the changes made so far before we do more refactoring?

It would be good to only change ResolveRequest if we absolutely have to.

@alsami
Copy link
Member Author

alsami commented Aug 11, 2020

What is the motivation behind making ResolveRequest an interface / abstract class?

Basically the requirement to make testing easier and only really have to mock what you need, since it has one constructor with all the parameters required.

I ask because it is a very small type, it can be relatively easily mocked (especially now), and it is very well established as a type you can instantiate and do stuff with. It's going to introduce a lot of extra breaking change.

I agree, this class has been public for a very long time probably. Most of the parameters can be rather easily mocked as well, but still require mocking.

Might I propose that we have a go updating the unit tests with the changes made so far before we do more refactoring?

We actually already did that, if you are talking about ResolveRequestContext. Or what is it, that you are referring to?

@alistairjevans
Copy link
Member

I'm thinking about things like ActivatorPipelineExtensions, which has been changed for the new naming, but not properly refactored to take advantage of the new abstract classes.

That class only exists because of how complex it used to be to mock a pipeline invocation.

I feel like we should try reworking things to use the new abstract classes before we do more refactoring.

We may have already made enough changes to satisfy #1164.

@alsami
Copy link
Member Author

alsami commented Aug 11, 2020

I'm thinking about things like ActivatorPipelineExtensions, which has been changed for the new naming, but not properly refactored to take advantage of the new abstract classes.

Okay cool, will look into it.

We may have already made enough changes to satisfy #1164.

Fine for me, I've just understood that it was kind of a nice to have to make it even easier in the specific area.

Closing this for now

@alsami alsami closed this Aug 11, 2020
@alistairjevans
Copy link
Member

Thanks; it might be we still need this, but it would be good to know for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants