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

TBD comments and local function support in Akka core #2697

Merged
merged 12 commits into from
Jun 8, 2017

Conversation

Aaronontheweb
Copy link
Member

No description provided.

Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Commenting on my changes.

Func<List<string>, Task<Done>> loop = null;
loop = remainingPhases =>

Task<Done> Loop(List<string> remainingPhases)
Copy link
Member Author

Choose a reason for hiding this comment

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

Local function optimization in CoordinatedShutdown, which should have minimal impact if any.

@@ -483,26 +481,24 @@ internal static List<string> TopologicalSort(Dictionary<string, Phase> phases)
var unmarked = new HashSet<string>(phases.Keys.Concat(phases.Values.SelectMany(x => x.DependsOn)));
var tempMark = new HashSet<string>(); // for detecting cycles

Action<string> depthFirstSearch = null;
depthFirstSearch = u =>
void DepthFirstSearch(string u)
Copy link
Member Author

Choose a reason for hiding this comment

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

Another local function optimization in CoordinatedShutdown. Minimal impact - this code only runs once per application.

@@ -375,8 +375,7 @@ private void ProcessMailbox(int left, long deadlineTicks)
{
while (ShouldProcessMessage())
{
Envelope next;
if (!TryDequeue(out next)) return;
if (!TryDequeue(out var next)) return;
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed mailbox to use new out var syntax. Don't expect this to have any real performance impact.

@@ -277,38 +277,36 @@ public MailboxType GetMailboxType(Props props, Config dispatcherConfig)
_mailboxSizeWarningIssued = true;
}

Func<MailboxType, MailboxType> verifyRequirements = mailboxType =>
MailboxType VerifyRequirements(MailboxType mailboxType)
Copy link
Member Author

Choose a reason for hiding this comment

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

This might be interesting - if the VerifyRequirements local function is able to be created using a value type, which the compiler tries to do by default, this might improve the rate at which we're able to spawn actors. Will check benchmark results to verify.

@alexvaluyskiy
Copy link
Contributor

@Aaronontheweb Where is a performance comparison?

@Aaronontheweb
Copy link
Member Author

Before

Akka.Tests.Performance.Actor.ActorMemoryFootprintSpec+ReceiveActor_memory_footprint

Measures the amount of memory used by 10,000 ReceiveActors
5/24/2017 4:56:56 PM

System Info

NBench=NBench, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null
OS=Microsoft Windows NT 6.2.9200.0
ProcessorCount=2
CLR=4.0.30319.42000,IsMono=False,MaxGcGeneration=2

NBench Settings

RunMode=Iterations, TestMode=Measurement
NumberOfIterations=13, MaximumRunTime=00:00:01
Concurrent=True
Tracing=True

Data


Totals

Metric Units Max Average Min StdDev
TotalBytesAllocated bytes 20,841,880.00 20,037,162.46 17,498,864.00 910,118.80
[Counter] ActorCreateThroughput operations 10,000.00 10,000.00 10,000.00 0.00

Per-second Totals

Metric Units / s Max / s Average / s Min / s StdDev / s
TotalBytesAllocated bytes 149,566,053.58 126,771,473.86 112,043,922.28 10,138,918.00
[Counter] ActorCreateThroughput operations 71,762.27 63,337.81 54,208.97 5,051.87

@Aaronontheweb
Copy link
Member Author

After

Akka.Tests.Performance.Actor.ActorMemoryFootprintSpec+ReceiveActor_memory_footprint

Measures the amount of memory used by 10,000 ReceiveActors
5/24/2017 3:40:00 PM

System Info

NBench=NBench, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null
OS=Microsoft Windows NT 6.2.9200.0
ProcessorCount=2
CLR=4.0.30319.42000,IsMono=False,MaxGcGeneration=2

NBench Settings

RunMode=Iterations, TestMode=Measurement
NumberOfIterations=13, MaximumRunTime=00:00:01
Concurrent=True
Tracing=True

Data


Totals

Metric Units Max Average Min StdDev
TotalBytesAllocated bytes 20,598,024.00 20,204,595.69 19,381,792.00 307,827.70
[Counter] ActorCreateThroughput operations 10,000.00 10,000.00 10,000.00 0.00

Per-second Totals

Metric Units / s Max / s Average / s Min / s StdDev / s
TotalBytesAllocated bytes 148,598,273.64 137,075,791.03 124,809,017.36 6,426,981.38
[Counter] ActorCreateThroughput operations 72,142.00 67,823.11 62,338.93 2,470.39

@Aaronontheweb
Copy link
Member Author

@alexvaluyskiy ActorCreateThroughput is virtually the same, but this benchmark may not be a reliable measure for any perf changes here since the actor type we're creating is the same each time. The JITer can optimize the code after warm-ups to re-use the same mailbox type and type check each time since it's always the same actor and same mailbox type. For the same reasons I mentioned on the other PR though, there's only upside to moving away from delegates to local functions here. Worst case scenario gets implemented the same way we've done it with Func<>, using a delegate on the heap.

@sean-gilliam
Copy link
Member

Another plus is that local functions are slightly easier and natural to read than Func<>.

@alexvaluyskiy alexvaluyskiy merged commit 95b07ab into akkadotnet:v1.3 Jun 8, 2017
Aaronontheweb added a commit to Aaronontheweb/akka.net that referenced this pull request Jun 28, 2017
* added comments to internals

* updated intellisense comments

* added comments for systemmessage

* added more local function support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants