-
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
ActorGraphInterpreter Box Caching #7116
base: dev
Are you sure you want to change the base?
ActorGraphInterpreter Box Caching #7116
Conversation
Waiting for feedback on approach before I provide benchmarks (Also have to make sure we have some good ones) But local testing on ValueTask branch indicates a 5-15% reduction in memory allocation on even existing async calls, with equal or improved performance throughout. |
@to11mtm I'll get to this this week with an initial review, but looks promising |
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.
If you could help explain the approach for why we're doing it this way, I'd have an easier time understanding this code some. Do you mind?
@@ -156,8 +245,8 @@ public GraphInterpreterShell(GraphAssembly assembly, Connection[] connections, G | |||
_settings = settings; | |||
Materializer = materializer; | |||
|
|||
_inputs = new ActorGraphInterpreter.BatchingActorInputBoundary[shape.Inlets.Count()]; | |||
_outputs = new ActorGraphInterpreter.IActorOutputBoundary[shape.Outlets.Count()]; | |||
_inputs = new ActorGraphInterpreter.BatchingActorInputBoundary[shape.Inlets.Length]; |
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.
LGTM
|
||
public GraphInterpreterShell Shell => Boxed.Shell; | ||
} | ||
internal sealed class BoxedOnNext : ActorGraphInterpreter.IBoundaryEvent |
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.
@to11mtm can you describe the approach / "why do it this way?" for me just so I understand the thinking behind this.
Of course and I apologize for terseness in this POC, the lift vs benefit got me a bit excited. :) Right now, What this PR does, is change some things up to minimize allocations.
The main purpose of the structure of said boxes, was to minimize overall code changes; since Where the 'maybes' come in:
|
@to11mtm got it - benchmark it and let's see if it makes any difference. I'd probably prefer to just move everything to classes than having clever object pooling stuff that can bite us in the butt. Alternatively, maybe we can use generics or something else to stick with |
Generic Boxes looks... IDK They do seem to somehow add some extra jitter to benchmarks 🤷♂️ but the reduced code bloat is worth it, unless the benchmarks Actual benchmark numbers are in next reply (trying to get better about bench spam), I had to re-run everything with a more 'fair' pool abstraction (original one was too ugly even for my taste, new one I'm re-benching before commit is fair, but still probably can be improved.) That said in general stuff looks... curious. I have bad jitter luck on my box, which complicates comparing branches at times. I think there's something small I'm missing, as I see 'equal or slightly better' perf, or 'maybe slightly worse or test jitter' perf... memory allocation is definitely improved though
Well, the pooling still helps; If we used classes but didn't pool, we may save on unbox vagaries but still will be allocating. And, Ironically, I have to say that the 'box pool' made this easy to do safely. We pull the struct out of the 'box', pass it to the next thing, the box use is all 'internal' to I should also add, after some looking, Box-pools -may- be a solution for some other challenges we have around |
After:
before
|
Fixes #
Changes
Adds Box-Pools for various
struct
messages used byActorGraphInterpreter
Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):
Latest
dev
BenchmarksTBD after feedback
This PR's Benchmarks
TBD after feedback