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
WorldRenderer, replace ActorsWithTraits with ApplyToActorsWithTrait. #19557
Conversation
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.
Didn't notice any issues
World.ApplyToActorsWithTrait<IRenderShroud>((Actor actor, IRenderShroud trait) => | ||
trait.RenderShroud(this)); |
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.
World.ApplyToActorsWithTrait<IRenderShroud>((Actor actor, IRenderShroud trait) => | |
trait.RenderShroud(this)); | |
World.ApplyToActorsWithTrait<IRenderShroud>((Actor actor, IRenderShroud trait) => trait.RenderShroud(this)); |
Did you measure the impact of #18798 (comment) ( |
Not in exact numbers. However there is an significant overhead. |
e499b4f
to
40c9ba5
Compare
@teinarss would you be able to do some of your benchmarking tests on this? |
Best way is to pull the specific code out and do a benchmark with
https://benchmarkdotnet.org/index.html
…On Sun, 25 Jul 2021, 00:48 Paul Chote, ***@***.***> wrote:
@teinarss <https://github.com/teinarss> would you be able to do some of
your benchmarking tests on this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19557 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AESI7GENXQT7ISWWEY7X63DTZM7LTANCNFSM5A4UREBQ>
.
|
See also #18357 (comment) |
I let the RA shellmap run for 5000 ticks for 3 runs, alternating pr/before/pr/before/pr/before and looked at the render_prepare (which is what calls The before/after results overlap within the scatter of the 3 runs, so there doesn't seem to be any significant impact either way and we can instead consider this on code style/consistency grounds. |
@@ -153,14 +153,14 @@ void GenerateRenderables() | |||
// PERF: Avoid LINQ. | |||
void GenerateOverlayRenderables() | |||
{ | |||
foreach (var a in World.ActorsWithTrait<IRenderAboveShroud>()) | |||
World.ApplyToActorsWithTrait<IRenderAboveShroud>((Actor actor, IRenderAboveShroud trait) => |
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.
And likewise here.
@@ -195,14 +195,14 @@ void GenerateOverlayRenderables() | |||
// PERF: Avoid LINQ. | |||
void GenerateAnnotationRenderables() | |||
{ | |||
foreach (var a in World.ActorsWithTrait<IRenderAnnotations>()) | |||
World.ApplyToActorsWithTrait<IRenderAnnotations>((Actor actor, IRenderAnnotations trait) => |
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.
Its not necessary to specify all three types here. This could be either
World.ApplyToActorsWithTrait<IRenderAnnotations>((actor, trait) =>
or
World.ApplyToActorsWithTrait>((Actor actor, IRenderAnnotations trait) =>
IMO the first is easier to read.
foreach (var a in World.ActorsWithTrait<IRenderAboveWorld>()) | ||
if (a.Actor.IsInWorld && !a.Actor.Disposed) | ||
a.Trait.RenderAboveWorld(a.Actor, this); | ||
World.ApplyToActorsWithTrait<IRenderAboveWorld>((Actor actor, IRenderAboveWorld trait) => |
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.
And here, and below.
Adding a |
40c9ba5
to
ff0b756
Compare
ff0b756
to
3bc3555
Compare
Closes #18798.
At least 2 to 4.2 times less ticks are used - by avoiding the allocation of Trait Actor pairs that use generics.
I.e. 2442 ticks before, 571 ticks after.