csgo-osx-linux icon indicating copy to clipboard operation
csgo-osx-linux copied to clipboard

[Performance/Engine] Frame pacing spikes on 64 Hz server ticks caused by synchronous Fork-Join barrier in scenesystem.dll

Open 1337Shameless opened this issue 1 month ago • 0 comments

Your system information:

https://gist.github.com/1337Shameless/73844b763f3b6e9865dc68726cec9754


Please describe your issue in as much detail as possible:

During active gameplay, the engine exhibits periodic frame pacing degradation and severe frametime spikes that repeat precisely every 15.6 ms (the 1/64 s server tick interval). Low-level profiling across Intel PresentMon, Superluminal, and Windows Performance Analyzer (WPA) reveals that these stalls are caused by a synchronous Fork-Join barrier where the Main Thread enters a kernel wait state, halting execution and starving the GPU command queue.

1. PresentMon Telemetry: 15.6 ms Tick-Aligned GPU Starvation

Capturing frametimes with Intel PresentMon isolates clockwork latency spikes aligned with incoming server packets:

  • MsGPUBusy remains completely flat at ~1.2 ms, confirming the GPU has plenty of headroom and is not encountering shading or geometry bottlenecks.
  • MsGPUWait mirrors the frametime spikes with an $r = 0.83$ correlation, indicating that over 80% of the frametime hitching is caused by the GPU sitting completely idle, waiting for the CPU to submit work.
  • Every 15.6 ms, incoming server tick data halts render submission, driving instantaneous frametimes into sharp repeating peaks. Image
2. Superluminal Profiler: Synchronous Barrier & Tail Latency

Profiling thread interaction in Superluminal during these frame pacing spikes shows the exact bottleneck inside scenesystem.dll and tier0.dll:

  • Main Thread Suspension: MainThrd enters state Synchronization and remains blocked inside the Windows kernel.
  • Frame Budget Depletion: On high-end configurations targeting 300+ FPS, the target frame budget is $\le 3.33\text{ ms}$. A kernel stall consumes over 90% to 100% of the entire frame budget on a single synchronous wait before any draw submission can occur.
  • Worker Dependency (Straggler Effect): MainThrd is held hostage waiting for individual worker threads inside GlobPool to complete and signal.
Image
3. WPA ETW Analysis: Excessive Context Switching Friction

Analyzing precise CPU usage and context switches (KiSwapContext) in Windows Performance Analyzer highlights massive scheduler overhead across the 15 worker threads (GlobPool/0 to GlobPool/14):

  • Severe Switch Rates: Over 1,234,900 context switches recorded within a 14.77-second trace—amounting to over 83,500 context switches per second.
  • Frequent Kernel Sleeps: Worker threads average ~4,770 wakeups/sec, with 96% of switch-ins originating from blocking kernel waits. Workers execute short compute slices (~50 µs) followed by kernel waits (~150 µs).
  • Scheduler Queue Latency: Worker threads exhibit scheduling Ready queue spikes of up to 1,100–1,127 µs (~1.13 ms). Because the Main Thread waits synchronously on WaitForMultipleObjects, any OS scheduling delay or compute variance on the slowest worker directly translates into an immediate frame stall on the Main Thread.
Image

Describe what you expected should happen and what did happen:

  • Expected behavior: On a high-end system frame delivery should remain smooth and consistent, with render submission decoupled from background tick simulation so that incoming server packets do not stall the presentation thread.
  • Actual behavior: Incoming 64 Hz tick packets trigger a synchronous Fork-Join barrier. The Main Thread halts execution via WaitForMultipleObjects awaiting GlobPool workers, exhausting the frame budget, starving the GPU (MsGPUWait spike), and causing severe micro-stutter and input inconsistency.

Steps for reproducing this issue:

  1. Launch Counter-Strike 2 and join any 64-tick server (official matchmaking or casual).
  2. Attach Intel PresentMon and record frame metrics (MsGPUBusy, MsGPUWait, Frametime) during active engagements. Observe cyclical frametime spikes matching the 15.6 ms tick period alongside correlated MsGPUWait jumps.
  3. Attach Superluminal or capture an ETW kernel trace using Windows Performance Recorder (WPR) with Context Switch and CPU sampling enabled.
  4. Inspect MainThrd execution: filter by state Synchronization.
  5. Verify the blocking callstack halting on ZwWaitForMultipleObjects and observe the duration until unblocked by GlobPool workers executing SetEvent.

1337Shameless avatar Oct 13 '26 00:10 1337Shameless