-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Improve performance on IActorRef.Child
API
#5242
Changes from all commits
9a50416
0aa7122
bf6e162
fdac3b9
bc91ad8
d754014
3910d11
f8f5342
3197d0c
6b590d7
8cce9b7
16e33c8
702d7b8
26db634
bc66127
075159b
d04e5a7
9f8b852
83224be
60b3537
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,6 @@ namespace Akka.Actor | |
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]")] | ||
public Akka.Actor.IInternalActorRef GetSingleChild(string name) { } | ||
public void Init(bool sendSupervise, Akka.Dispatch.MailboxType mailboxType) { } | ||
public Akka.Actor.Internal.ChildRestartStats InitChild(Akka.Actor.IInternalActorRef actor) { } | ||
|
@@ -127,7 +126,6 @@ namespace Akka.Actor | |
public void TerminatedQueuedFor(Akka.Actor.IActorRef subject, Akka.Util.Option<object> customMessage) { } | ||
public bool TryGetChildStatsByName(string name, out Akka.Actor.Internal.IChildStats child) { } | ||
protected bool TryGetChildStatsByRef(Akka.Actor.IActorRef actor, out Akka.Actor.Internal.ChildRestartStats child) { } | ||
public bool TryGetSingleChild(string name, out Akka.Actor.IInternalActorRef child) { } | ||
public void UnbecomeStacked() { } | ||
protected void UnreserveChild(string name) { } | ||
public Akka.Actor.IActorRef Unwatch(Akka.Actor.IActorRef subject) { } | ||
|
@@ -1081,7 +1079,7 @@ namespace Akka.Actor | |
bool IsTerminated { get; } | ||
Akka.Actor.IInternalActorRef Parent { get; } | ||
Akka.Actor.IActorRefProvider Provider { get; } | ||
Akka.Actor.IActorRef GetChild(System.Collections.Generic.IEnumerable<string> name); | ||
Akka.Actor.IActorRef GetChild(System.Collections.Generic.IReadOnlyList<string> name); | ||
void Restart(System.Exception cause); | ||
void Resume(System.Exception causedByFailure = null); | ||
[System.ObsoleteAttribute("Use SendSystemMessage(message) [1.1.0]")] | ||
|
@@ -1202,7 +1200,7 @@ namespace Akka.Actor | |
public abstract bool IsTerminated { get; } | ||
public abstract Akka.Actor.IInternalActorRef Parent { get; } | ||
public abstract Akka.Actor.IActorRefProvider Provider { get; } | ||
public abstract Akka.Actor.IActorRef GetChild(System.Collections.Generic.IEnumerable<string> name); | ||
public abstract Akka.Actor.IActorRef GetChild(System.Collections.Generic.IReadOnlyList<string> name); | ||
public abstract void Restart(System.Exception cause); | ||
public abstract void Resume(System.Exception causedByFailure = null); | ||
[System.ObsoleteAttribute("Use SendSystemMessage(message) instead [1.1.0]")] | ||
|
@@ -1245,7 +1243,7 @@ namespace Akka.Actor | |
protected Akka.Actor.IInternalActorRef Supervisor { get; } | ||
protected Akka.Actor.ActorSystem System { 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) { } | ||
public override Akka.Actor.IInternalActorRef GetSingleChild(string name) { } | ||
protected virtual Akka.Actor.ActorCell NewActorCell(Akka.Actor.Internal.ActorSystemImpl system, Akka.Actor.IInternalActorRef self, Akka.Actor.Props props, Akka.Dispatch.MessageDispatcher dispatcher, Akka.Actor.IInternalActorRef supervisor) { } | ||
public override void Restart(System.Exception cause) { } | ||
|
@@ -1317,7 +1315,7 @@ namespace Akka.Actor | |
[System.ObsoleteAttribute("Use Context.Watch and Receive<Terminated> [1.1.0]")] | ||
public override bool IsTerminated { get; } | ||
public override Akka.Actor.IInternalActorRef Parent { 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) { } | ||
public override void Restart(System.Exception cause) { } | ||
public override void Resume(System.Exception causedByFailure = null) { } | ||
public override void SendSystemMessage(Akka.Dispatch.SysMsg.ISystemMessage message) { } | ||
|
@@ -1533,7 +1531,7 @@ namespace Akka.Actor | |
public override Akka.Actor.ActorPath Path { get; } | ||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Source-compatible, but not necessarily a binary-compatible change. |
||
public override Akka.Actor.IInternalActorRef GetSingleChild(string name) { } | ||
public Akka.Actor.RepointableActorRef Initialize(bool async) { } | ||
protected virtual Akka.Actor.ActorCell NewCell() { } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,11 +156,9 @@ protected override void TellInternal(object message, IActorRef sender) | |
} | ||
} | ||
|
||
var t = Rec(ImmutableList<string>.Empty); | ||
var concatenatedChildNames = t.Item1; | ||
var m = t.Item2; | ||
var (concatenatedChildNames, m) = Rec(ImmutableList<string>.Empty); | ||
|
||
var child = GetChild(concatenatedChildNames); | ||
var child = GetChild(concatenatedChildNames.ToList()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra allocation in remote deployments here.... might see if I can go about fixing that still.... |
||
if (child.IsNobody()) | ||
{ | ||
var emptyRef = new EmptyLocalActorRef(_system.Provider, | ||
|
@@ -302,7 +300,7 @@ private void HandleDaemonMsgCreate(DaemonMsgCreate message) | |
/// </summary> | ||
/// <param name="name">The name.</param> | ||
/// <returns>ActorRef.</returns> | ||
public override IActorRef GetChild(IEnumerable<string> name) | ||
public override IActorRef GetChild(IReadOnlyList<string> name) | ||
{ | ||
var path = name.Join("/"); | ||
var n = 0; | ||
|
@@ -313,7 +311,7 @@ public override IActorRef GetChild(IEnumerable<string> name) | |
{ | ||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another allocation in remote deployments |
||
} | ||
|
||
var last = path.LastIndexOf("/", StringComparison.Ordinal); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,58 +353,37 @@ protected bool TryGetChildStatsByRef(IActorRef actor, out ChildRestartStats chil | |
/// </summary> | ||
/// <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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Half the perf optimizations happened here:
|
||
{ | ||
IInternalActorRef child; | ||
return TryGetSingleChild(name, out child) ? child : ActorRefs.Nobody; | ||
} | ||
|
||
|
||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
/// <param name="name">TBD</param> | ||
/// <param name="child">TBD</param> | ||
/// <returns>TBD</returns> | ||
public bool TryGetSingleChild(string name, out IInternalActorRef child) | ||
{ | ||
if (name.IndexOf('#') < 0) | ||
{ | ||
// optimization for the non-uid case | ||
if (TryGetChildRestartStatsByName(name, out var stats)) | ||
if (ChildrenContainer.TryGetByName(name, out var stats) && stats is ChildRestartStats r) | ||
{ | ||
child = stats.Child; | ||
return true; | ||
return r.Child; | ||
} | ||
else if (TryGetFunctionRef(name, out var functionRef)) | ||
|
||
if (TryGetFunctionRef(name, out var functionRef)) | ||
{ | ||
child = functionRef; | ||
return true; | ||
return functionRef; | ||
} | ||
} | ||
else | ||
{ | ||
var (s, uid) = GetNameAndUid(name); | ||
if (TryGetChildRestartStatsByName(s, out var stats)) | ||
if (TryGetChildRestartStatsByName(s, out var stats) && (uid == ActorCell.UndefinedUid || uid == stats.Uid)) | ||
{ | ||
if (uid == ActorCell.UndefinedUid || uid == stats.Uid) | ||
{ | ||
child = stats.Child; | ||
return true; | ||
} | ||
return stats.Child; | ||
} | ||
else if (TryGetFunctionRef(s, uid, out var functionRef)) | ||
|
||
if (TryGetFunctionRef(s, uid, out var functionRef)) | ||
{ | ||
child = functionRef; | ||
return true; | ||
return functionRef; | ||
} | ||
} | ||
child = ActorRefs.Nobody; | ||
return false; | ||
return ActorRefs.Nobody; | ||
} | ||
|
||
/// <summary> | ||
/// TBD | ||
/// </summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
TryGetSingleChild
since no one was actually using its boolean functionality at all