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

Projects
None yet
5 participants
@RoosterDragon
Copy link
Member

RoosterDragon commented Mar 15, 2018

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();

This comment has been minimized.

@pchote

pchote Mar 15, 2018

Member

Can we include a // PERF: comment here?

@reaperrr

This comment has been minimized.

Copy link
Contributor

reaperrr commented Mar 16, 2018

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.

@RoosterDragon RoosterDragon force-pushed the RoosterDragon:reuse-hashset-frozen-actor branch from dc5cfd0 to 73081f0 Mar 17, 2018


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

This comment has been minimized.

@chrisforbes

chrisforbes Mar 18, 2018

Member

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

This comment has been minimized.

@RoosterDragon

RoosterDragon Mar 18, 2018

Author Member

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

This comment has been minimized.

@chrisforbes

chrisforbes Mar 18, 2018

Member

Correct.

@abcdefg30 abcdefg30 merged commit 3b642b1 into OpenRA:bleed Mar 18, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@RoosterDragon RoosterDragon deleted the RoosterDragon:reuse-hashset-frozen-actor branch Mar 18, 2018

@abcdefg30

This comment has been minimized.

Copy link
Member

abcdefg30 commented Mar 18, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.