Repository navigation
Check the PC sampling gap before synchronizing the context - #55
Merged
Merged
Conversation
Under parca-agent, the launch callback calls PCSampling::start() every 30 ms per launching thread. start() synchronized the context first and only then, under the lock, found it was still inside the gap and returned. So every check drained the GPU: about 33 full context synchronizations a second per thread, whatever window and gap the agent set. start() now returns before the synchronize while the gap since the last window has not passed. The check under the lock stays, for a window that closes in between. On an 8x RTX PRO 6000 node (vLLM and SGLang, decode-heavy load, agent window 30 ms / gap 10 s) the synchronize took 37-64% of the engine thread's CPU samples and throughput fell 50-75%, getting worse the longer it ran. The same loss showed with the agent's 10 ms / 10 s and its defaults, which is why measured cost did not follow the duty cycle.
gnurizen
marked this pull request as draft
November 23, 2026 14:44
gnurizen
marked this pull request as ready for review
November 23, 2026 17:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under parca-agent, the launch callback calls
PCSampling::start()every 30 ms for each thread that launches kernels (kPCSamplingIntervalNs).start()calledcuCtxSynchronizefirst. Only after that, underpcSamplingMutex, did it find it was still inside the gap and return false. So every check drained the GPU: about 33 full context synchronizations a second per launching thread, whatever window and gap the agent set.start()now checks the gap before the synchronize. The check under the lock stays, for a window that closes in between.What we measured
CoreWeave, 8x RTX PRO 6000 node, vLLM and SGLang serving a decode-heavy load, agent window 30 ms / gap 10 s, release shim:
PCSampling::start→ libcuda (spinning in the synchronize) accounted for 64% of samples on vLLM and 37% on SGLang.start()returns before the synchronize.A GPU A/B of this fix on the same node is running now. I'll add the numbers here.
Testing
cuCtxSynchronizeis a no-op. A test would have to count synchronizations across launches inside a gap. I can add that if you'd like it.