Skip to content

Improve pulse sleep on busy servers (#4853)#4893

Open
Zephkek wants to merge 1 commit intomultitheftauto:masterfrom
Zephkek:fix/4853-pulse-sleep
Open

Improve pulse sleep on busy servers (#4853)#4893
Zephkek wants to merge 1 commit intomultitheftauto:masterfrom
Zephkek:fix/4853-pulse-sleep

Conversation

@Zephkek
Copy link
Copy Markdown
Contributor

@Zephkek Zephkek commented May 4, 2026

Summary

HandlePulseSleep returns as soon as the sync thread queues work, instead of always sleeping busy_sleep_time first.

Motivation (#4853)

With threadnet, the old path slept 20 ms (busy_sleep_time) before checking PendingWorkToDo. On busy servers (~600 players), this capped the logic thread while m_InResultQueue kept growing, causing chat lag/loss with CPU still moderate.

Change

Replaced the fixed top-of-pulse sleep + tail loop with a ~1 ms polling loop that returns the moment PendingWorkToDo() is true.

  • Idle: still uses full idle_sleep_time.
  • Busy: wakes as work arrives; server_logic_fps_limit is still the hard cap.
  • idle_sleep_time = 0 is now actually 0 (was clamped to 1).
  • busy_sleep_time is no longer used here. Option still parses and shows in perf info.

Test plan

Code review only (HandlePulseSleep, PendingWorkToDo, GetSleepIntervals). No 600-player test rig, so this needs operator confirmation that logic FPS isn't pinned near 1000 / busy_sleep_time under sustained inbound queue.

Checklist

HandlePulseSleep now returns as soon as the sync thread queues work,
instead of sleeping busy_sleep_time at the start of every pulse.

Mitigates multitheftauto#4853 (high player count chat lag / packet loss with low CPU):
with threadnet, the unconditional sleep could cap DoPulse while m_InResultQueue
still grew. Replaced with a short 1ms polling loop that exits on PendingWorkToDo.

Idle path unchanged (full idle_sleep_time). server_logic_fps_limit remains
the hard cap. busy_sleep_time is no longer used on this path (option still parses).

Test plan: code review only; needs 600+ player confirmation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant