Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 17 additions & 25 deletions src/Ydb.Sdk/test/Ydb.Sdk.Ado.Benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,22 @@ Allocated : Allocated memory per single operation (managed only, incl

# YDB .NET SDK Session Pool V1 On Semaphore-Based

| Method | Mean | Error | StdDev | Completed Work Items | Lock Contentions | Gen0 | Gen1 | Allocated |
|-------------------------------------|-----------------:|----------------:|----------------:|---------------------:|-----------------:|----------:|-------:|-----------:|
| SingleThreaded_OpenClose | 126.0 ns | 0.85 ns | 0.71 ns | 0.0000 | - | 0.0257 | - | 216 B |
| MultiThreaded_OpenClose | 36,028.4 ns | 710.14 ns | 1,146.75 ns | 40.0003 | 0.5005 | 1.4038 | - | 11582 B |
| HighContention_OpenClose | 155,614.4 ns | 3,083.73 ns | 5,400.90 ns | 230.8015 | 5.5818 | 8.7891 | 0.4883 | 74780 B |
| SessionReuse_Pattern | 203,350.5 ns | 2,675.74 ns | 2,371.97 ns | 220.0027 | 5.5349 | 5.8594 | - | 50511 B |
| SessionReuse_HighIterations_Pattern | 145,221,373.7 ns | 1,843,163.83 ns | 1,724,096.59 ns | 200020.2500 | 1764.5000 | 5000.0000 | - | 43209728 B |
| Method | Mean | Error | StdDev | Completed Work Items | Lock Contentions | Gen0 | Gen1 | Allocated |
|-------------------------------------|-----------------:|----------------:|----------------:|---------------------:|-----------------:|----------:|---------:|-----------:|
| SingleThreaded_OpenClose | 125.1 ns | 2.54 ns | 2.37 ns | - | - | 0.0257 | - | 216 B |
| MultiThreaded_OpenClose | 30,893.8 ns | 610.63 ns | 895.06 ns | 40.0002 | 0.3741 | 1.4038 | - | 11573 B |
| HighContention_OpenClose | 159,192.9 ns | 3,168.43 ns | 6,752.19 ns | 230.7124 | 5.6448 | 8.7891 | 0.4883 | 74723 B |
| SessionReuse_Pattern | 202,559.0 ns | 2,181.67 ns | 1,934.00 ns | 220.0027 | 5.4810 | 5.8594 | - | 50510 B |
| SessionReuse_HighContention_Pattern | 10,016,874.4 ns | 58,462.60 ns | 54,685.95 ns | 19707.6719 | 165.5469 | 921.8750 | 140.6250 | 7729448 B |
| SessionReuse_HighIterations_Pattern | 152,765,644.4 ns | 1,570,755.95 ns | 1,469,286.09 ns | 200020.0000 | 1751.2500 | 5000.0000 | - | 43207568 B |

# YDB .NET SDK Session Pool Benchmarks
# YDB .NET SDK Session Pool Benchmarks (Npgsql)

| Method | Mean | Error | StdDev | Completed Work Items | Lock Contentions | Gen0 | Allocated |
|-------------------------------------|-----------------:|---------------:|---------------:|---------------------:|-----------------:|-------:|----------:|
| SingleThreaded_OpenClose | 25.35 ns | 0.258 ns | 0.241 ns | - | - | - | - |
| MultiThreaded_OpenClose | 30,650.91 ns | 601.279 ns | 1,281.374 ns | 40.0031 | 0.5160 | 0.8545 | 7249 B |
| HighContention_OpenClose | 142,804.56 ns | 2,845.384 ns | 7,138.512 ns | 205.9829 | 4.6663 | 4.6387 | 38864 B |
| SessionReuse_Pattern | 153,983.59 ns | 2,272.104 ns | 2,014.161 ns | 220.0000 | 5.6296 | 0.7324 | 7303 B |
| SessionReuse_HighIterations_Pattern | 82,351,234.51 ns | 694,703.573 ns | 649,826.153 ns | 200020.0000 | 540.0000 | - | 7458 B |

# YDB .NET SDK Session Source Benchmarks (Npgsql)

| Method | Mean | Error | StdDev | Median | Completed Work Items | Lock Contentions | Gen0 | Allocated |
|--------------------------|--------------:|-------------:|-------------:|--------------:|---------------------:|-----------------:|-------:|----------:|
| SingleThreaded_OpenClose | 25.82 ns | 0.141 ns | 0.125 ns | 25.78 ns | - | - | - | - |
| MultiThreaded_OpenClose | 20,893.61 ns | 829.087 ns | 2,431.569 ns | 19,694.30 ns | 20.0033 | 0.0303 | 0.5188 | 4526 B |
| HighContention_OpenClose | 108,688.27 ns | 2,160.177 ns | 3,298.819 ns | 108,755.99 ns | 100.0017 | 3.8002 | 2.5635 | 21839 B |
| SessionReuse_Pattern | 130,849.34 ns | 2,616.397 ns | 4,977.967 ns | 129,920.39 ns | 20.0000 | 5.4443 | 0.4883 | 4588 B |

| Method | Mean | Error | StdDev | Completed Work Items | Lock Contentions | Gen0 | Gen1 | Allocated |
|-------------------------------------|-----------------:|---------------:|---------------:|---------------------:|-----------------:|---------:|--------:|----------:|
| SingleThreaded_OpenClose | 26.34 ns | 0.476 ns | 0.422 ns | - | - | - | - | - |
| MultiThreaded_OpenClose | 32,578.44 ns | 650.578 ns | 1,583.596 ns | 40.0028 | 0.4411 | 0.8545 | - | 7251 B |
| HighContention_OpenClose | 138,930.59 ns | 2,729.363 ns | 4,990.795 ns | 209.1182 | 3.5857 | 4.8828 | - | 40566 B |
| SessionReuse_Pattern | 159,954.05 ns | 2,820.324 ns | 4,044.825 ns | 220.0000 | 6.0381 | 0.7324 | - | 7307 B |
| SessionReuse_HighContention_Pattern | 8,914,529.81 ns | 46,900.448 ns | 41,576.026 ns | 19756.6563 | 149.0469 | 625.0000 | 93.7500 | 5289794 B |
| SessionReuse_HighIterations_Pattern | 81,211,792.96 ns | 749,115.160 ns | 664,071.077 ns | 200020.0000 | 614.8571 | - | - | 7458 B |
23 changes: 23 additions & 0 deletions src/Ydb.Sdk/test/Ydb.Sdk.Ado.Benchmarks/SessionPoolBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,29 @@ public async Task SessionReuse_Pattern()
await Task.WhenAll(tasks);
}

[Benchmark]
public async Task SessionReuse_HighContention_Pattern()
{
const int iterations = 100;
const int highContentionTasks = 100;
var tasks = new Task[highContentionTasks];

for (var i = 0; i < highContentionTasks; i++)
{
tasks[i] = Task.Run(async () =>
{
for (var j = 0; j < iterations; j++)
{
var session = await _sessionPool.GetSession();
await Task.Yield();
await session.Release();
}
});
}

await Task.WhenAll(tasks);
}

[Benchmark]
public async Task SessionReuse_HighIterations_Pattern()
{
Expand Down
23 changes: 23 additions & 0 deletions src/Ydb.Sdk/test/Ydb.Sdk.Ado.Benchmarks/SessionSourceBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,29 @@ public async Task SessionReuse_Pattern()
await Task.WhenAll(tasks);
}

[Benchmark]
public async Task SessionReuse_HighContention_Pattern()
{
const int iterations = 100;
const int highContentionTasks = 100;
var tasks = new Task[highContentionTasks];

for (var i = 0; i < highContentionTasks; i++)
{
tasks[i] = Task.Run(async () =>
{
for (var j = 0; j < iterations; j++)
{
var session = await _poolingSessionSource.OpenSession();
await Task.Yield();
session.Close();
}
});
}

await Task.WhenAll(tasks);
}

[Benchmark]
public async Task SessionReuse_HighIterations_Pattern()
{
Expand Down
Loading