Page MenuHomeWildfire Games

petra: further improve performance in structure placement
ClosedPublic

Authored by mimo on Sep 5 2017, 7:54 PM.

Details

Summary

rP20093 has improved the performance when the AI looks for a good position for its structures, but some of them (mainly civil centre) are still rather slow because the AI has to check obstructions on many possible positions. This patch improves that by caching the cell which obstructed the previous tested position, and checking it first before doing the full check of the next position. As a lot of nearby positions are tested, this improves a lot the performance as seen on the plot attached which represents the total time taking by the AI script for a game with 4 AIs on Caspian Sea (2v2). Huge spikes are clearly visible in the svn profile, which have disappeared in the patched profile (both had the exact same hash value).

Test Plan

check that this indeed improves performance

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mimo created this revision.Sep 5 2017, 7:54 PM
Vulcan added a subscriber: Vulcan.Sep 5 2017, 8:50 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

http://jenkins-master:8080/job/phabricator/1976/ for more details.

Vulcan added a comment.Sep 5 2017, 8:51 PM
Executing section Default...
Executing section Source...
Executing section JS...

binaries/data/mods/public/simulation/ai/common-api/map-module.js
| 276| »   if·(kx·<·radius·||·kx·>=·w·-·radius·||·ky·<·radius·||·ky·>=·w·-·radius·||·this.map[kx+ky*w]·==·0)
|    | [NORMAL] JSHintBear:
|    | Use '===' to compare with '0'.

binaries/data/mods/public/simulation/ai/common-api/map-module.js
| 292| »   »   »   if·(this.map[xp·+·dx]·==·0)
|    | [NORMAL] JSHintBear:
|    | Use '===' to compare with '0'.

binaries/data/mods/public/simulation/ai/common-api/map-module.js
| 294| »   »   »   if·(this.map[xm·+·dx]·==·0)
|    | [NORMAL] JSHintBear:
|    | Use '===' to compare with '0'.

binaries/data/mods/public/simulation/ai/common-api/map-module.js
| 296| »   »   »   if·(this.map[xp·-·dx]·==·0)
|    | [NORMAL] JSHintBear:
|    | Use '===' to compare with '0'.

binaries/data/mods/public/simulation/ai/common-api/map-module.js
| 298| »   »   »   if·(this.map[xm·-·dx]·==·0)
|    | [NORMAL] JSHintBear:
|    | Use '===' to compare with '0'.
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jenkins-master:8080/job/phabricator_lint/491/ for more details.

This revision was automatically updated to reflect the committed changes.