Opened 20 months ago

Closed 19 months ago

Last modified 19 months 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:

Description

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: https://github.com/wraitii/0ad/commits/guardRewrite . All changes in the one commit.

Attachments (1)

guard-4333.patch (8.7 KB) - added by mimo 19 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 20 months ago by stanislas69

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 Changed 19 months ago by elexis

Milestone: Alpha 22Work In Progress

Moving to the new WIP milestone.

comment:3 Changed 19 months ago by mimo

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.

Changed 19 months ago by mimo

Attachment: guard-4333.patch added

comment:4 Changed 19 months ago by wraitii

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

comment:5 Changed 19 months ago by mimo

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 Changed 19 months ago by mimo

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