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

Decorator Performance Improvements #1194

Merged
merged 2 commits into from
Aug 26, 2020
Merged

Conversation

alistairjevans
Copy link
Member

These changes largely bring decorators "back into the fold" performance-wise; most of the improvement is about when we update the decorator context; doing it in the start of the 'next' decorator means we avoid an additional allocation, list copy, etc.

@alistairjevans
Copy link
Member Author

@autofac-bot help

@alistairjevans
Copy link
Member Author

Updated benchmarks:

Slower diff/base Base Median (ns) Diff Median (ns) Modality
Autofac.Benchmarks.ConcurrencyNestedScopeBenchmark.MultipleResolvesOnMultipleTas 1.18 924407.13 1086364.45
Autofac.Benchmarks.Decorators.KeyedGenericBenchmark.ResolveT(repetitions: 3) 1.07 2356.29 2519.59
Autofac.Benchmarks.MultiConstructorBenchmark.TwoValidOneInvalid 1.05 1261.16 1323.43
Autofac.Benchmarks.MultiConstructorBenchmark.Three 1.04 1444.09 1499.22
Autofac.Benchmarks.Decorators.KeyedNestedBenchmark.ResolveEnumerableT(repetition 1.03 4873.63 5032.59
Autofac.Benchmarks.MultiConstructorBenchmark.Four 1.03 1965.53 2023.38
Autofac.Benchmarks.EnumerableResolveBenchmark.ResolveArray 1.03 2340.16 2408.55
Autofac.Benchmarks.MultiConstructorBenchmark.Two 1.03 972.79 997.51
Autofac.Benchmarks.PropertyInjectionBenchmark.Resolve 1.02 3423.63 3508.78
Faster base/diff Base Median (ns) Diff Median (ns) Modality
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceBenchmark.ResolveEnumer 1.17 5974.32 5093.79
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceBenchmark.ResolveEnumer 1.15 3975.46 3450.35
Autofac.Benchmarks.Decorators.KeylessGenericBenchmark.ResolveEnumerableT(repetit 1.15 7850.09 6849.69
Autofac.Benchmarks.Decorators.KeylessGenericBenchmark.ResolveEnumerableT(repetit 1.15 5446.14 4753.48
Autofac.Benchmarks.Decorators.KeylessSimpleLambdaBenchmark.ResolveEnumerableT(re 1.14 3294.25 2901.87
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceLambdaBenchmark.Resolve 1.13 2617.58 2311.90
Autofac.Benchmarks.Decorators.KeylessNestedBenchmark.ResolveT(repetitions: 3) 1.12 5021.81 4464.18
Autofac.Benchmarks.Decorators.KeylessSimpleBenchmark.ResolveEnumerableT(repetiti 1.12 5618.12 5010.91
Autofac.Benchmarks.Decorators.KeylessGenericBenchmark.ResolveT(repetitions: 2) 1.12 2425.32 2165.06
Autofac.Benchmarks.Decorators.KeylessSimpleBenchmark.ResolveEnumerableT(repetiti 1.12 3319.96 2967.72
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceLambdaBenchmark.Resolve 1.12 3062.60 2739.73
Autofac.Benchmarks.Decorators.KeylessNestedBenchmark.ResolveT(repetitions: 2) 1.12 3581.97 3208.27
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceLambdaBenchmark.Resolve 1.11 7484.37 6729.53
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceLambdaBenchmark.Resolve 1.11 5671.41 5100.39
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceBenchmark.ResolveT(repe 1.11 2499.81 2253.78
Autofac.Benchmarks.Decorators.KeylessSimpleLambdaBenchmark.ResolveEnumerableT(re 1.11 7955.84 7180.25
Autofac.Benchmarks.Decorators.KeylessSimpleBenchmark.ResolveEnumerableT(repetiti 1.10 8098.43 7346.22
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceBenchmark.ResolveT(repe 1.10 3105.78 2820.93
Autofac.Benchmarks.Decorators.KeylessGenericBenchmark.ResolveT(repetitions: 1) 1.10 1488.91 1354.08
Autofac.Benchmarks.Decorators.KeylessSimpleLambdaBenchmark.ResolveEnumerableT(re 1.10 5525.81 5026.30
Autofac.Benchmarks.Decorators.KeylessNestedBenchmark.ResolveT(repetitions: 1) 1.10 2191.83 1996.92
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceBenchmark.ResolveEnumer 1.10 10494.35 9561.94
Autofac.Benchmarks.Decorators.KeylessSimpleBenchmark.ResolveT(repetitions: 3) 1.10 3330.07 3037.48
Autofac.Benchmarks.Decorators.KeylessGenericBenchmark.ResolveT(repetitions: 3) 1.09 3107.50 2845.08
Autofac.Benchmarks.Decorators.KeylessSimpleLambdaBenchmark.ResolveT(repetitions: 1.09 1553.88 1422.90
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceLambdaBenchmark.Resolve 1.09 3499.82 3209.36
Autofac.Benchmarks.Decorators.KeylessSimpleLambdaBenchmark.ResolveT(repetitions: 1.09 2424.32 2225.42
Autofac.Benchmarks.Decorators.KeylessNestedLambdaBenchmark.ResolveT(repetitions: 1.09 3440.83 3161.45
Autofac.Benchmarks.Decorators.KeylessGenericBenchmark.ResolveEnumerableT(repetit 1.09 3033.64 2790.12
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceBenchmark.ResolveEnumer 1.08 7519.33 6937.52
Autofac.Benchmarks.Decorators.KeylessSimpleLambdaBenchmark.ResolveT(repetitions: 1.08 3227.32 2986.54
Autofac.Benchmarks.Decorators.KeylessNestedBenchmark.ResolveEnumerableT(repetiti 1.08 4309.06 3989.67
Autofac.Benchmarks.Decorators.KeylessNestedLambdaBenchmark.ResolveT(repetitions: 1.08 4798.24 4447.08
Autofac.Benchmarks.Decorators.KeylessNestedBenchmark.ResolveEnumerableT(repetiti 1.07 10988.67 10230.11
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceBenchmark.ResolveT(repe 1.07 4518.52 4210.01
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceLambdaBenchmark.Resolve 1.07 1795.17 1677.95
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceLambdaBenchmark.Resolve 1.06 10222.28 9622.94
Autofac.Benchmarks.Decorators.KeylessNestedLambdaBenchmark.ResolveEnumerableT(re 1.06 4266.81 4024.29
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceBenchmark.ResolveEnumer 1.06 5087.33 4812.55
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceBenchmark.ResolveEnumer 1.06 7848.62 7436.56
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceBenchmark.ResolveT(repe 1.05 3529.61 3347.48
Autofac.Benchmarks.Decorators.KeylessNestedLambdaBenchmark.ResolveT(repetitions: 1.05 2091.16 1984.18
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceLambdaBenchmark.Resolve 1.05 4435.50 4211.69
Autofac.Benchmarks.Decorators.KeylessSimpleBenchmark.ResolveT(repetitions: 1) 1.05 1564.21 1485.60
Autofac.Benchmarks.Decorators.KeylessNestedLambdaBenchmark.ResolveEnumerableT(re 1.05 7672.17 7303.95
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceBenchmark.ResolveT(repe 1.05 1825.26 1740.18
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceLambdaBenchmark.Resolve 1.05 7756.23 7420.87
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceLambdaBenchmark.Resolve 1.05 4983.38 4768.37
Autofac.Benchmarks.Decorators.KeyedSimpleBenchmark.ResolveEnumerableT(repetition 1.04 4137.51 3961.79
Autofac.Benchmarks.Decorators.KeylessNestedBenchmark.ResolveEnumerableT(repetiti 1.04 7457.67 7146.31
Autofac.Benchmarks.MultiConstructorBenchmark.Single 1.04 603.39 579.72
Autofac.Benchmarks.Decorators.KeylessNestedLambdaBenchmark.ResolveEnumerableT(re 1.04 10965.56 10562.30
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceBenchmark.ResolveT(repe 1.03 2447.10 2368.16
Autofac.Benchmarks.Decorators.KeylessNestedSharedInstanceLambdaBenchmark.Resolve 1.03 2405.16 2329.38
Autofac.Benchmarks.Decorators.KeylessSimpleSharedInstanceLambdaBenchmark.Resolve 1.03 3646.91 3539.17
Autofac.Benchmarks.Decorators.KeyedSimpleBenchmark.ResolveT(repetitions: 2) 1.03 1673.75 1625.73
Autofac.Benchmarks.Decorators.KeylessSimpleBenchmark.ResolveT(repetitions: 2) 1.03 2439.28 2369.93
Autofac.Benchmarks.Decorators.KeyedGenericBenchmark.ResolveT(repetitions: 2) 1.03 1879.18 1826.04
Autofac.Benchmarks.Decorators.KeyedSimpleBenchmark.ResolveEnumerableT(repetition 1.02 5598.69 5468.19
Autofac.Benchmarks.Decorators.KeyedGenericBenchmark.ResolveEnumerableT(repetitio 1.02 4360.38 4259.31

@codecov
Copy link

codecov bot commented Aug 26, 2020

Codecov Report

Merging #1194 into develop will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1194      +/-   ##
===========================================
+ Coverage    75.78%   75.79%   +0.01%     
===========================================
  Files          189      189              
  Lines         4678     4680       +2     
  Branches       956      956              
===========================================
+ Hits          3545     3547       +2     
  Misses         676      676              
  Partials       457      457              
Impacted Files Coverage Δ
...rc/Autofac/Features/Decorators/DecoratorContext.cs 100.00% <100.00%> (ø)
...Autofac/Features/Decorators/DecoratorMiddleware.cs 90.90% <100.00%> (+0.43%) ⬆️

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 dea64b5...67c7630. Read the comment docs.

Copy link
Member

@tillig tillig left a comment

Choose a reason for hiding this comment

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

🍢

@tillig tillig merged commit c8b1081 into autofac:develop Aug 26, 2020
@alistairjevans alistairjevans mentioned this pull request Aug 28, 2020
3 tasks
@alistairjevans alistairjevans deleted the perf branch August 29, 2020 06:55
@alistairjevans alistairjevans added this to the v6.0 milestone Sep 26, 2020
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