-
Notifications
You must be signed in to change notification settings - Fork 200
Throttle strafing air lookahead to avoid O(n²) spikes #2686
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
base: master
Are you sure you want to change the base?
Throttle strafing air lookahead to avoid O(n²) spikes #2686
Conversation
|
Context and rationale: - Large fighter blobs issuing mass move/attack orders were causing O(n^2)-like spikes from CStrafeAirMoveType repeatedly calling AAirMoveType::CheckForCollision with a 200 elmo radius every 4 frames per unit. The results were discarded (�voidCollision was always false), so the heavy quad-field scans provided no steering benefit while hammering perf. What changed: - CheckForCollision now accepts an optional radius, enabling callers to choose a tighter, cheaper probe without touching other air move types. - StrafeAir lookahead is now bounded and staggered: only every 8 frames per unit, and radius clamped to 80–160 elmos scaled by turn radius/speed, still gated by collide. This preserves a minimal anticipatory check (better than removing it) while avoiding the prior unbounded work in big swarms. Why this is preferable to removing the scan entirely:- Keeps gentle preemptive avoidance for fast movers (fewer rubber-band corrections) but caps both frequency and search radius so it scales in large groups. Testing:- Docker build: docker-build-v2/build.sh linux -DBUILD_spring-headless=OFF -DBUILD_spring-dedicated=OFF (ghcr.io/beyond-all-reason/recoil-build-amd64-linux:latest) passed; only compiler warnings. |
it's already "throttled", all this actually does is tweak numerical values
this is still the case with this PR, but also you mention fighter screens in the context/rationale which tend to have collide=false so don't even run a scan in the first place.
reducing values is going to make collision avoidance worse
where is this formula from?
all you did was tweak numerical constants. it's still O(n²)
there better be perf measurements if we're going to make behaviour worse, and manual testing for whether the new values introduce bad edge cases in existing games. |
|
The original tweak was a constant‑factor perf guard: strafers were still calling CheckForCollision every 4 frames with a 200 radius even though avoidCollision was off, so the scan results were thrown away. I tightened radius and frequency to cut that wasted work without touching other air move types or deleting the hook, in case we ever re-enable avoidance. After your point that the scans remained unused and still O(n²), I’ve now removed the strafing lookahead calls entirely. Behavior is unchanged (avoidance still off), and we stop paying for unused quad scans. If we decide to revive avoidance later, we’ll reintroduce it with measured perf/behavior data. I am working on changes with actual perf results and will add those next. |
i didn't say it remains unused, i said it remains O(n²). i don't know if it's completely unused but your OP claims it does something after all, in which case removal is incorrect. either way it would be best to fix collisions, since any game interested in saving perf can turn them off anyway. |
Summary
Testing