Repository navigation
Improve performance on IActorRef.Child API - #5242
Conversation
| public override Akka.Actor.IActorRefProvider Provider { get; } | ||
| public override Akka.Actor.ICell Underlying { get; } | ||
| public override Akka.Actor.IActorRef GetChild(System.Collections.Generic.IEnumerable<string> name) { } | ||
| public override Akka.Actor.IActorRef GetChild(System.Collections.Generic.IReadOnlyList<string> name) { } |
There was a problem hiding this comment.
Source-compatible, but not necessarily a binary-compatible change.
|
Looks like this may have broken cluster formation based on some of the testing I'm doing locally. I'll check it out some once I get reports back from the test suite. |
|
Looks like there's some work still to be done with the |
|
So once #5243 gets merged, new baseline numbers for New numbers BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.302
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
Numbers for this PR: BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.302
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
Top level actor resolves (i.e. ones that go through Akka.Cluster.Sharding) got a lot faster, but ones beneath the top-level actors stayed pretty much the same. |
…heweb/akka.net into perf/improve-ResolveAPI
This reverts commit 8cce9b7.
|
BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.302
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
On this PR: Forgot to add baseline numbers for this: BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.302
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
|
|
|
||
| public T this[int index] | ||
| { | ||
| get => _array.ElementAt(Offset + index); |
There was a problem hiding this comment.
Since _array is an IReadOnlyList<T> here we may be better off using the Indexer on that interface rather than ElementAt.
- If
_arraydoes not also implementIList<T>we will force an enumeration .ElementAtadds additional null and type checks even in best case.
There was a problem hiding this comment.
Ah yes, that's a bit of leftovers from when I was using IReadOnlyCollection instead of IReadOnlyList - the former doesn't have an indexer. I'll update that.
|
Even better numbers after fixing the indexer operation BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.302
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
|
|
Although IMHO those differences are probably in the margin of error |
|
I wonder if getting rid of these deeply nested |
|
Perf numbers from simplified branching: BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.302
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
|
|
Perf numbers from removing redundant BenchmarkDotNet=v0.13.1, OS=Windows 10.0.19041.1165 (2004/May2020Update/20H1)
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores
.NET SDK=5.0.302
[Host] : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
DefaultJob : .NET Core 3.1.17 (CoreCLR 4.700.21.31506, CoreFX 4.700.21.31502), X64 RyuJIT
|
| public System.Collections.Generic.IEnumerable<Akka.Actor.IInternalActorRef> GetChildren() { } | ||
| public static Akka.Actor.IActorRef GetCurrentSelfOrNoSender() { } | ||
| public static Akka.Actor.IActorRef GetCurrentSenderOrNoSender() { } | ||
| [System.ObsoleteAttribute("Use TryGetSingleChild [0.7.1]")] |
There was a problem hiding this comment.
Removed TryGetSingleChild since no one was actually using its boolean functionality at all
| var (concatenatedChildNames, m) = Rec(ImmutableList<string>.Empty); | ||
|
|
||
| var child = GetChild(concatenatedChildNames); | ||
| var child = GetChild(concatenatedChildNames.ToList()); |
There was a problem hiding this comment.
Extra allocation in remote deployments here.... might see if I can go about fixing that still....
| if (uid != ActorCell.UndefinedUid && uid != child.Path.Uid) | ||
| return Nobody.Instance; | ||
| return n == 0 ? child : child.GetChild(name.TakeRight(n)); | ||
| return n == 0 ? child : child.GetChild(name.TakeRight(n).ToList()); |
There was a problem hiding this comment.
Another allocation in remote deployments
| /// <param name="name">N/A</param> | ||
| /// <returns>N/A</returns> | ||
| [Obsolete("Use TryGetSingleChild [0.7.1]")] | ||
| public IInternalActorRef GetSingleChild(string name) |
There was a problem hiding this comment.
Half the perf optimizations happened here:
- Simplified branching
- Remove
Try... outstuff since it was all functionally being converted back intoActorRefs.Nobodyanyway.
| /// <see cref="ArraySegment{T}"/> but for <see cref="IReadOnlyList{T}"/> | ||
| /// </summary> | ||
| /// <typeparam name="T"></typeparam> | ||
| internal struct ListSlice<T> : IList<T>, IReadOnlyList<T> |
There was a problem hiding this comment.
Basically an ArraySegment that takes a type of IReadOnlyList<T>
Builds upon #5241, but introduces some breaking API changes.
Performance numbers:
devThis PR