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

[Akka.Actor][Perf] Reduce Envelope copying in message-processing hotpaths #6830

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Jul 11, 2023

Changes

Depends on #6829

While working on some performance fixes for Phobos we noticed some significant improvements by passing all structs handled inside a tight loop as in parameters into subsequent methods - this helps reduce message copying by allowing the "lower stack" to reference the memory previously allocated in the "upper stack"

Since this handling is all synchronous, there's no cost to using in parameters in these areas - and we saw a significant upside in processing performance, as much as 10% in a single instance so far.

Based on that work, I decided to give that a try with how we handle the Envelope payloads inside Akka.Actor - as these are also structs that are passed around in tight loops.

This PR introduces some API changes but these should all be binary compatible, minus any libraries that intentionally override these methods - those will need to be updated to also include the in parameter on those methods.

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Latest dev Benchmarks

From the PingPong benchmark inside Akka.Benchmarks:

BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22621.1848)
12th Gen Intel Core i7-1260P, 1 CPU, 16 logical and 12 physical cores
.NET SDK=7.0.302
  [Host]     : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
  Job-VSSPYZ : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2

InvocationCount=1  IterationCount=10  LaunchCount=10  
RunStrategy=Monitoring  UnrollFactor=1  WarmupCount=10  
Method Mean Error StdDev Req/sec
Actor_ping_pong_single_pair_in_memory 244.2 ns 1.75 ns 5.15 ns 4,095,040.09

This PR's Benchmarks

BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22621.1848)
12th Gen Intel Core i7-1260P, 1 CPU, 16 logical and 12 physical cores
.NET SDK=7.0.302
  [Host]     : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
  Job-HBAPGK : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2

InvocationCount=1  IterationCount=10  LaunchCount=10  
RunStrategy=Monitoring  UnrollFactor=1  WarmupCount=10  
Method Mean Error StdDev Req/sec
Actor_ping_pong_single_pair_in_memory 242.6 ns 1.60 ns 4.71 ns 4,122,578.29

IMHO - kind of looks like the benefits of this fall within the margin of error.

@Aaronontheweb Aaronontheweb added this to the 1.5.9 milestone Jul 11, 2023
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.9, 1.5.11, 1.5.12 Jul 25, 2023
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.12, 1.5.13 Aug 2, 2023
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.13, 1.5.14 Sep 20, 2023
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.14, 1.5.15 Nov 29, 2023
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.15, 1.5.16 Jan 10, 2024
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.16, 1.5.17 Jan 31, 2024
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.17, 1.5.18 Mar 5, 2024
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.18, 1.5.19 Mar 12, 2024
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.19, 1.5.20 Apr 15, 2024
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.20, 1.5.21 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant