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

[Performance/Streaming] Mid-game frame drop caused by synchronous SleepConditionVariableSRW wait on AsyncIOService

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 and map navigation, the engine experiences severe frametime spikes and noticeable freezes caused by synchronous asset streaming waits executed directly on the Main Thread. Thread interaction profiling in Superluminal reveals that MainThrd enters a kernel wait state on a Condition Variable (SleepConditionVariableSRW) awaiting filesystem data completion from AsyncIOService/0, causing an immediate frame stall of ~6.14 ms.

1. Profiler Trace: ~6.14 ms Main Thread Freeze on Asset Streaming

Profiling thread interaction during mid-game traversal isolates a major synchronous I/O bottleneck:

  • Stall Duration: MainThrd is halted for 6ms 144µs (~6.14 ms) in state Synchronization.
  • Frame Budget Impact: On high-end configurations targeting 300+ FPS (frame budget $\le 3.33\text{ ms}$), a single 6.144 ms kernel stall consumes nearly two full frames on an idle wait alone. Instantaneous framerate collapses to ~100–120 FPS, creating an aggressive, perceptible hitch during movement.
  • Unblocking Entity: MainThrd is held waiting until worker thread AsyncIOService/0 finishes processing filesystem data and signals completion via ThreadWakeConditionVariable.
2. Blocking Callstack: Synchronous SleepConditionVariableSRW

The callstack captures the world rendering and material pipeline blocking on disk/package streaming instead of operating asynchronously:

Blocking Callstack (MainThrd):

client.dll!0xDC09C0
worldrenderer.dll!0x2506E
worldrenderer.dll!0x23183
materialsystem2.dll!0x83DA3
filesystem_stdio.dll!0xA4B22
tier0.dll!ThreadSleepConditionVariableSRW
KERNELBASE.dll!SleepConditionVariableSRW
ntdll.dll!RtlSleepConditionVariableSRW
ntdll.dll!ZwWaitForSingleObject
ntoskrnl.exe!KeWaitForSingleObject
ntoskrnl.exe!KiCommitThreadWait
ntoskrnl.exe!KiSwapContext

Unblocking Callstack (AsyncIOService/0):

filesystem_stdio.dll!0x4B77
tier0.dll!ThreadWakeConditionVariable
ntdll.dll!RtlWakeThreadByThreadId
ntoskrnl.exe!KiWakeThreadByThreadId
ntoskrnl.exe!KiReadyThread

While background streaming is theoretically delegated to AsyncIOService/0, worldrenderer.dll and materialsystem2.dll block the presentation thread synchronously via SleepConditionVariableSRW when a required material or geometry resource is not yet resident in memory.

Image

Describe what you expected should happen and what did happen:

  • Expected behavior: Resource streaming during active gameplay should be non-blocking. If a texture, decal, or mesh resource is queued for loading, MainThrd should proceed with rendering (using fallbacks, lower mipmaps, or deferred drawing) without stalling the presentation thread on filesystem operations.
  • Actual behavior: MainThrd halts synchronously inside filesystem_stdio.dll on a Condition Variable for 6.144 ms awaiting AsyncIOService/0, causing an instantaneous frametime spike and severe frame hitching during live matches.

Steps for reproducing this issue:

  1. Launch Counter-Strike 2 and load into any active map.
  2. Attach Superluminal (or capture an ETW kernel trace with context switch and wait callstacks enabled).
  3. Move through different areas of the map to trigger dynamic material, model, or world geometry streaming.
  4. Locate frametime spikes on MainThrd and filter callstacks by SleepConditionVariableSRW.
  5. Observe MainThrd blocked in state Synchronization awaiting unblock signals from AsyncIOService/0.

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