Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#4333 closed enhancement (fixed)

[Patch] Speed up the Guard component

Reported by: wraitii Owned by: mimo
Priority: Must Have Milestone: Alpha 22
Component: UI & Simulation Keywords: patch
Cc: Patch:


The guard component is quite slow for no good reason. It uses OnGlobalOwnershipChanged, and since so many entities have a guard component, it becomes really slow when any ownership changed message gets sent.

I have changed it very slightly to not do that. Makes it go from a weird performance bottleneck to basically irrelevant, as it should be.

Putting as must have because it's actually a huge optimisation for the change.

Branch is here: . All changes in the one commit.

Attachments (1)

guard-4333.patch (8.7 KB ) - added by mimo 7 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Stan, 8 years ago

Line 65 of guard.js since you actually nuke the var keyword you should also nuke the for each.

Jslinting the file might be nice I think.

comment:2 by elexis, 7 years ago

Milestone: Alpha 22Work In Progress

Moving to the new WIP milestone.

comment:3 by mimo, 7 years ago

When reviewing this patch, i noticed 2 problems in the original code:

  • diplomacyChanges were not taken into account
  • line 87 of Guard.js looks wrong to me

And in your patch, the taking account of renamed entities is only partial.

I've attached a new patch which should fix all of that.

by mimo, 7 years ago

Attachment: guard-4333.patch added

comment:4 by wraitii, 7 years ago

Looks good. For the promotion/transform.js change, I'd commit those as part of #4334 Feel free to commit it.

comment:5 by mimo, 7 years ago

Owner: set to mimo
Resolution: fixed
Status: newclosed

In 19026:

Speed up the guard component by removing OnGlobal calls, based on a patch from wraitii, fixes #4333

comment:6 by mimo, 7 years ago

Keywords: review removed
Milestone: Work In ProgressAlpha 22
Note: See TracTickets for help on using tickets.