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

Fix memory degradation #255

Merged
merged 31 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9464d89
added test for #254
dadhi Apr 5, 2020
f1df0e6
ignoring the failed test
dadhi Apr 5, 2020
e2208a6
Cherry pick commit 'c7f698c'
dadhi Apr 5, 2020
a4e6e4e
Cherry pick commit '285214f'
dadhi Apr 5, 2020
c7db763
Cherry pick commit '7dec0b9'
dadhi Apr 5, 2020
fbf3181
Cherry pick commit '0a2091a'
dadhi Apr 5, 2020
d5aff9e
Cherry pick commit '517c44f'
dadhi Apr 5, 2020
36751b7
Cherry pick commit '5d07bc6'
dadhi Apr 5, 2020
2c01fa2
Cherry pick commit '41eb818'
dadhi Apr 5, 2020
0bc9c10
#254 - make the obsoletion of RegisterDelegateDecorator in the next m…
dadhi Apr 5, 2020
6097989
added: simplest case FactoryMethod constructor and updated the usages
dadhi Apr 5, 2020
63573bd
simplifying ParameterServiceInfo.Of
dadhi Apr 5, 2020
5325709
removing the code doing nothing
dadhi Apr 5, 2020
a453d56
added: test with singleton decorator for #254
dadhi Apr 6, 2020
1d59624
revert back to the Match because using UpdateItemOrShrinkUnsafe is po…
dadhi Apr 6, 2020
55419ee
#254 reimplement RegisterDelegateDecorator in terms of RegisterDelegate
dadhi Apr 7, 2020
f99f307
cleanup unused things
dadhi Apr 7, 2020
bb478fb
dead code cleanup
dadhi Apr 7, 2020
1d5a913
sharing the RequestStack for the Validate
dadhi Apr 8, 2020
6e9687c
optimizing out double GetParameters when parameters are already resol…
dadhi Apr 8, 2020
a17d533
enable back ignored NCrunch test including ReducedStackoverflow
dadhi Apr 8, 2020
1e080c4
small cleanup
dadhi Apr 8, 2020
eee11a1
added sorting benchmark and implemented decorator sorting for more th…
dadhi Apr 8, 2020
25c1788
small comments cleanup
dadhi Apr 10, 2020
c8d98ce
-2kb by removing unnecassery creation of FactoryMethod
dadhi Apr 12, 2020
43b860c
fixed: #254
dadhi Apr 12, 2020
2d2248b
dadhi Apr 12, 2020
5127472
improving the error messages
dadhi Apr 12, 2020
bf1334b
release notes for the v4.1.4
dadhi Apr 12, 2020
b6029ad
Merge branch 'refs/heads/master' into fix-memory-degradation
dadhi Apr 13, 2020
e4bc3fe
updated benchmarks
dadhi Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions playground/LoadTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,44 @@ public static IContainer CreateContainer()
return container;
}

/*
## v4.1.5 - Singleton decorators

Validation finished
00:01:24.33

ResolveAllControllersOnce of 156 controllers is done in 0.1533677 seconds

----------------------------------
Starting compiled + cached tests
----------------------------------

New container created

container with ambient ScopeContext DryIoc.AsyncExecutionFlowScopeContext without scope
with Rules with Made={FactoryMethod=ConstructorWithResolvableArguments}

ResolveAllControllersOnce of 156 controllers is done in 0.0073486 seconds
ResolveAllControllersOnce of 156 controllers is done in 0.1591292 seconds
-- Starting Load test --
32 Threads.

-- Load Test Finished --
00:00:00.16

New container created

container with ambient ScopeContext DryIoc.AsyncExecutionFlowScopeContext without scope
with Rules with Made={FactoryMethod=ConstructorWithResolvableArguments}

ResolveAllControllersOnce of 156 controllers is done in 0.0080617 seconds
ResolveAllControllersOnce of 156 controllers is done in 0.1478801 seconds
-- Starting Randomized Load test --
155 Threads.

-- Randomized Load Finished --
00:00:00.36
*/
static /*async Task*/void Main(string[] args)
{
Console.WriteLine("Starting up!");
Expand Down
4 changes: 1 addition & 3 deletions playground/Playground/ImMapBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ public class Lookup
TryFind_v1 | 200 | 6.886 ns | 0.0354 ns | 0.0331 ns | 1.52 | 0.03 | - | - | - | - |
ConcurrentDict_TryGet | 200 | 10.162 ns | 0.0355 ns | 0.0315 ns | 2.25 | 0.06 | - | - | - | - |

*/


*/
public V1.ImMap<string> AddOrUpdate_v1()
{
var map = V1.ImMap<string>.Empty;
Expand Down
97 changes: 97 additions & 0 deletions playground/Playground/ManualInserttionSortVsOrderBy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using System.Linq;
using BenchmarkDotNet.Attributes;

namespace Playground
{
[MemoryDiagnoser]
public class ManualInserttionSortVsOrderBy
{
public Thing[] things =
{
new Thing(1, 0),
new Thing(5, 0),
new Thing(3, 0),
new Thing(4, 0),
new Thing(6, 0),
};

public Thing[] things2 =
{
new Thing(1, 1),
new Thing(1, 3),
new Thing(1, 2),
new Thing(2, 1),
new Thing(2, 2),
};

[Benchmark(Baseline = true)]
public Thing[] SortViaInsertion()
{
InsertionSort2(things2);
return things;
}

[Benchmark]
public Thing[] SortViaOrderBy()
{
return things.OrderByDescending(x => x.X).ThenByDescending(x => x.Y).ToArray();
}

public struct Thing
{
public int X;
public int Y;
public Thing(int x, int y)
{
X = x;
Y = y;
}

public override string ToString() => X + ", " + Y;
}

public static void InsertionSort(Thing[] items)
{
int i, j;
for (i = 1; i < items.Length; i++)
{
var it = items[i];

for (j = i; j >= 1 && it.X > items[j - 1].X; j--)
{
ref var target = ref items[j];
var source = items[j - 1];
target.X = source.X;
}

ref var x = ref items[j];
x.X = it.X;
}
}

public static void InsertionSort2(Thing[] items)
{
int i, j;
for (i = 1; i < items.Length; --i)
{
var it = items[i];

for (j = i;
j >= 1 &&
(it.X > items[j - 1].X ||
it.X == items[j - 1].X && it.Y > items[j - 1].Y);
--j)
{
ref var target = ref items[j];
var source = items[j - 1];
target.X = source.X;
target.Y = source.Y;
}

ref var x = ref items[j];
x.X = it.X;
x.Y = it.Y;
}
}
}
}
8 changes: 6 additions & 2 deletions playground/Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public class Program
{
public static void Main()
{
//var bm = new ManualInserttionSortVsOrderBy();
//bm.SortViaInsertion();
//BenchmarkRunner.Run<ManualInserttionSortVsOrderBy>();

//BenchmarkRunner.Run<MatchCaseOrder>();

//BenchmarkRunner.Run<ImMapBenchmarks.Populate>();
Expand All @@ -39,8 +43,8 @@ public static void Main()
//BenchmarkRunner.Run<RealisticUnitOfWorkBenchmark.CreateContainerAndRegisterServices>();
//BenchmarkRunner.Run<RealisticUnitOfWorkBenchmark.FirstTimeOpenScopeAndResolve>();
//BenchmarkRunner.Run<RealisticUnitOfWorkBenchmark.SecondTimeOpenScopeAndResolve>();
//BenchmarkRunner.Run<RealisticUnitOfWorkBenchmark.CreateContainerAndRegisterServices_Then_FirstTimeOpenScopeAndResolve>();
BenchmarkRunner.Run<RealisticUnitOfWorkBenchmark.OpenScopeAndResolve>();
BenchmarkRunner.Run<RealisticUnitOfWorkBenchmark.CreateContainerAndRegisterServices_Then_FirstTimeOpenScopeAndResolve>();
//BenchmarkRunner.Run<RealisticUnitOfWorkBenchmark.OpenScopeAndResolve>();

//CloseToRealLifeUnitOfWorkWithBigObjectGraphBenchmark.Measure(
//CloseToRealLifeUnitOfWorkWithBigObjectGraphBenchmark.PrepareDryIocMsDi());
Expand Down
18 changes: 13 additions & 5 deletions playground/Playground/RealisticUnitOfWorkBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,14 @@ public class CreateContainerAndRegisterServices_Then_FirstTimeOpenScopeAndResolv
| Autofac | 583.26 us | 18.342 us | 17.157 us | 5.84 | 0.21 | 102.5391 | 28.3203 | - | 472.86 KB |
| Autofac_MsDI | 561.82 us | 4.129 us | 3.862 us | 5.63 | 0.20 | 101.5625 | 27.3438 | - | 467.85 KB |

## DryIoc v4.1.5

| Method | Mean | Error | StdDev | Ratio | Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------ |----------:|---------:|---------:|------:|--------:|-------:|------:|----------:|
| MsDI | 141.78 us | 1.687 us | 1.578 us | 1.00 | 16.8457 | 0.2441 | - | 73.16 KB |
| DryIoc | 98.96 us | 0.203 us | 0.180 us | 0.70 | 14.4043 | - | - | 66.87 KB |
| DryIoc_MsDI | 123.55 us | 1.721 us | 1.526 us | 0.87 | 19.1650 | - | - | 88.35 KB |
/
*/

[Benchmark(Baseline = true)]
Expand All @@ -1061,19 +1069,19 @@ public class CreateContainerAndRegisterServices_Then_FirstTimeOpenScopeAndResolv
//[Benchmark]
public object DryIoc_InterpretationOnly() => Measure(PrepareDryIocInterpretationOnly());

[Benchmark]
//[Benchmark]
public object Grace() => Measure(PrepareGrace());

[Benchmark]
//[Benchmark]
public object Grace_MsDI() => Measure(PrepareGraceMsDi());

[Benchmark]
//[Benchmark]
public object Lamar_MsDI() => Measure(PrepareLamarMsDi());

[Benchmark]
//[Benchmark]
public object Autofac() => Measure(PrepareAutofac());

[Benchmark]
//[Benchmark]
public object Autofac_MsDI() => Measure(PrepareAutofacMsDi());
}

Expand Down
Loading