Page MenuHomeWildfire Games

Optimise FindWalkAndFightTargets
Needs ReviewPublic

Authored by wraitii on Jan 21 2021, 9:09 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

I noticed when replaying a 1v1 with Freagarach (see below) that FindWalkAndFightTargets (attack-move) is slow, sufficiently to contribute noticeable lag with enough units.

This is a straightforward optimisation, that unfortunately changes hashes.

The idea is that most often, the first unit in rhe range query will actually pass all filters, because units have rather general preferred classes and units are the most common targets in a given area (structures are larger, thus sparser). This way, we can actually avoid filtering _and_ sorting.

Attached is profiling test on combat-demo (mid)

Test Plan

Play a regular game with attack walk. See also "combat demo (mid)" map to profile the changes.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
temp
Lint
Lint OK
SeverityLocationCodeMessage
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:342ESLintBear (consistent-return)ESLintBear (consistent-return)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:784ESLintBear (no-else-return)ESLintBear (no-else-return)
Warningbinaries/data/mods/public/simulation/components/UnitAI.js:2155ESLintBear (operator-linebreak)ESLintBear (operator-linebreak)
Unit
No Unit Test Coverage
Build Status
Buildable 15332
Build 33413: Vulcan BuildJenkins
Build 33412: Vulcan Build (macOS)Jenkins
Build 33411: Vulcan Build (Windows)Jenkins
Build 33410: arc lint + arc unit

Event Timeline

wraitii created this revision.Jan 21 2021, 9:09 PM
Owners added a subscriber: Restricted Owners Package.Jan 21 2021, 9:09 PM
wraitii edited the summary of this revision. (Show Details)Jan 21 2021, 9:10 PM

Build is green

builderr-debug-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libengine_dbg.a(precompiled.o) has no symbols
ld: warning: text-based stub file /System/Library/Frameworks//CoreAudio.framework/CoreAudio.tbd and library file /System/Library/Frameworks//CoreAudio.framework/CoreAudio are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//AudioToolbox.framework/AudioToolbox.tbd and library file /System/Library/Frameworks//AudioToolbox.framework/AudioToolbox are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//ForceFeedback.framework/ForceFeedback.tbd and library file /System/Library/Frameworks//ForceFeedback.framework/ForceFeedback are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreVideo.framework/Cor

See https://jenkins.wildfiregames.com/job/macos-differential/3009/display/redirect for more details.

wraitii requested review of this revision.Jan 21 2021, 9:16 PM
Stan added a subscriber: Stan.Jan 23 2021, 3:52 PM

A24 or A25?

In D3446#152808, @Stan wrote:

A24 or A25?

A25 I think. Too dangerous.