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

Reuse TargetTypes collection in FrozenActor.RefreshState. #14917

Merged
merged 1 commit into from Mar 18, 2018

Conversation

RoosterDragon
Copy link
Member

This is called a lot, and saves us reallocating a new hash set each time. Hopefully helps with #14905.

@@ -101,7 +101,8 @@ public FrozenActor(Actor actor, PPos[] footprint, Player viewer, bool startsReve
public void RefreshState()
{
Owner = actor.Owner;
TargetTypes = actor.GetEnabledTargetTypes().ToHashSet();
TargetTypes.Clear();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include a // PERF: comment here?

@reaperrr
Copy link
Contributor

Definitely a noticeable improvement, at least going by perf.log.

On bleed, 52 entries in first 2000 ticks on shellmap, many of them with 3-7 ms.
With this PR, only 17 entries in the same time with only 2 of them above 2 ms.

reaperrr
reaperrr previously approved these changes Mar 16, 2018

// PERF: Reuse collection to avoid allocations.
TargetTypes.Clear();
TargetTypes.UnionWith(actor.GetEnabledTargetTypes());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RoosterDragon TargetTypes seems like a great candidate for load-time bitsetification.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting class. Is the idea you specify Bits<SomeMarkerStruct> TargetTypes in multiple places and it automatically converts everything as it's loaded?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

@abcdefg30 abcdefg30 merged commit 3b642b1 into OpenRA:bleed Mar 18, 2018
@RoosterDragon RoosterDragon deleted the reuse-hashset-frozen-actor branch March 18, 2018 15:53
@abcdefg30
Copy link
Member

Changelog

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

5 participants