forked from akkadotnet/akka.net
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…s which support `IDisposable` will be disposed before `ActorSystem.WhenTerminated` completes. close akkadotnet#1593 - significantly improved upon the `DedicatedThreadScheduler` performance Signed-off-by: Aaron Stannard <aaron@petabridge.com>
- Loading branch information
1 parent
3db8e49
commit 9433e38
Showing
28 changed files
with
1,716 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
// <auto-generated/> | ||
//----------------------------------------------------------------------- | ||
// <copyright file="SharedAssemblyInfo.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
// <auto-generated/> | ||
using System.Reflection; | ||
|
||
[assembly: AssemblyCompanyAttribute("Akka.NET Team")] | ||
[assembly: AssemblyCopyrightAttribute("Copyright © 2013-2016 Akka.NET Team")] | ||
[assembly: AssemblyTrademarkAttribute("")] | ||
[assembly: AssemblyVersionAttribute("1.1.2.0")] | ||
[assembly: AssemblyFileVersionAttribute("1.1.2.0")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/core/Akka.Tests.Performance/Actor/Scheduler/DefaultSchedulerPerformanceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="DefaultSchedulerPerformanceTests.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2016 Akka.NET project <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using NBench; | ||
|
||
namespace Akka.Tests.Performance.Actor.Scheduler | ||
{ | ||
/// <summary> | ||
/// Designed to measure how many operations per-second the scheduler can perform in a fixed window of time. | ||
/// | ||
/// Meant to measure the efficiency of the default <see cref="IScheduler"/> and to see if there's much contention | ||
/// around the | ||
/// </summary> | ||
public class DefaultSchedulerPerformanceTests | ||
{ | ||
private ActorSystem _actorSystem; | ||
public const string ScheduledOps = "ScheduleInvokes"; | ||
private Counter _scheduledOpsCounter; | ||
public const string ScheduledJobs = "ScheduledJobs"; | ||
private Counter _jobsScheduled; | ||
private ICancelable _cancelSignal; | ||
|
||
/// <summary> | ||
/// number of concurrent schedulers | ||
/// </summary> | ||
private const int DegreeOfParallelism = 10; | ||
|
||
private const int SchedulePerBatch = 200; | ||
private static readonly TimeSpan RunTime = TimeSpan.FromSeconds(20); | ||
private Action _eventLoop; | ||
private Action _counterIncrement; | ||
|
||
public const int IterationCount = 1; // these are LONG-running benchmarks | ||
|
||
[PerfSetup] | ||
public void SetUp(BenchmarkContext context) | ||
{ | ||
_scheduledOpsCounter = context.GetCounter(ScheduledOps); | ||
_jobsScheduled = context.GetCounter(ScheduledJobs); | ||
_actorSystem = ActorSystem.Create("SchedulerPerformanceSpecs"); | ||
_cancelSignal = new Cancelable(_actorSystem.Scheduler); | ||
_counterIncrement = () => _scheduledOpsCounter.Increment(); | ||
|
||
_eventLoop = () => | ||
{ | ||
while (!_cancelSignal.IsCancellationRequested) | ||
{ | ||
for (var i = 0; i < SchedulePerBatch; i++) | ||
{ | ||
_actorSystem.Scheduler.Advanced.ScheduleRepeatedly(0, 10, _counterIncrement, _cancelSignal); | ||
_jobsScheduled.Increment(); | ||
} | ||
Thread.Sleep(40); // wait a bit, then keep going | ||
} | ||
}; | ||
} | ||
|
||
[PerfBenchmark(Description = "Tests to see how many concurrent jobs we can schedule and what the effects are on throughput", RunMode = RunMode.Iterations, NumberOfIterations = IterationCount)] | ||
[CounterMeasurement(ScheduledJobs)] | ||
[CounterMeasurement(ScheduledOps)] | ||
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] | ||
[GcMeasurement(GcMetric.TotalCollections, GcGeneration.AllGc)] | ||
public void SchedulerThroughputStressTest() | ||
{ | ||
for (var i = 0; i < DegreeOfParallelism; i++) | ||
{ | ||
Task.Factory.StartNew(_eventLoop); | ||
} | ||
Task.Delay(RunTime).Wait(); | ||
_cancelSignal.Cancel(false); | ||
} | ||
|
||
[PerfCleanup] | ||
public void CleanUp() | ||
{ | ||
_actorSystem.Terminate().Wait(); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.