Skip to content

AI Lag Bandaid#3786

Open
ondrej008 wants to merge 1 commit intoMonolith-Station:mainfrom
ondrej008:ai_lag_fix
Open

AI Lag Bandaid#3786
ondrej008 wants to merge 1 commit intoMonolith-Station:mainfrom
ondrej008:ai_lag_fix

Conversation

@ondrej008
Copy link
Copy Markdown
Contributor

@ondrej008 ondrej008 commented Apr 13, 2026

About the PR

Sort of resolves #3783

Why / Balance

So the client & server lag less

Media

Requirements

  • I have read relevant guidelines/documentation to this PR found on our devwiki.
  • I have added media to this PR or it does not require an ingame showcase.
  • I can confirm this PR contains either no AI-generated content, or AI-generated content that meets our guidelines.

How to test

test on live

Breaking changes

Changelog

🆑

  • fix: A relic from NanoTrasen has uncovered a way to make AI cores less compute intensive.

@ondrej008
Copy link
Copy Markdown
Contributor Author

also I do want to claim this for the bug bounty thing that nigel announced, though idc about in-game rewards

Copy link
Copy Markdown
Contributor

@EckoAurum EckoAurum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can understand where you're coming from, as you might see a performance increases in testing as you make it's vision single-threaded. But this will cause significantly more lag whenever there's more than single AI doing vision checks.

@ondrej008
Copy link
Copy Markdown
Contributor Author

I can understand where you're coming from, as you might see a performance increases in testing as you make it's vision single-threaded. But this will cause significantly more lag whenever there's more than single AI doing vision checks.

it is rare for there to be more than one AI in a single round, you can tell because whenever an AI is in the round lock contentions go up to 100 c/s (check with grafana) currently on live, so any round with lock contentions below 100 c/s has no AIs in it at all
also this should be tested on live before you make a statement like this
the code is not written to take account of multithreading as it spams lock contentions out the ass so much that the performance is worse than it being singlethreaded by 3x, this means that 3 AIs on singlethreaded should be the same as 1 AI on multithreaded mode

@ondrej008
Copy link
Copy Markdown
Contributor Author

ideally someone would rewrite the entire AI vision system to actually be multithreaded well but that would be a lot of work and needs a lot of C# multithreading and SS14 multithreading experience

@ondrej008
Copy link
Copy Markdown
Contributor Author

oh my god I just read the AI code someone go tell metalgearsloth to never touch multithreading again
a lock inside a for loop... I'll see if I can fix it without making it singlethreaded

@Redrover1760
Copy link
Copy Markdown
Contributor

Making it singlethreaded is not a fix, its a surrender of our multithreaded rights to the evils of the lag demons.

On that note good luck

@ondrej008
Copy link
Copy Markdown
Contributor Author

test on release multithreaded:
Zenith ADM client fps ~400, server fps 410-440
Zenith ADC client fps ~300, server fps 400-415

test on release singlethreaded:
Zenith ADM client fps ~400, server fps 410-440
Zenith ADC client fps ~350, server fps 400-420

so on my localhost I can't see much of a difference server-side, but it does improve client fps, idk

test on release multithreaded with changes:
Zenith ADM client fps ~400, server fps 410-440
Zenith ADC client fps ~240, server fps 360-410

apparently Microsoft's ConcurrentDictionary which is supposedly magically lock-free is not lock-free after all, had about 50% or 100% more lock contentions
will continue the search for a better datastructure or maybe just give up

@ondrej008
Copy link
Copy Markdown
Contributor Author

nvm I found something good, 400-420 server fps and 350 client fps w/ multihreading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AIs massively hurt client & server performance

3 participants