Repository navigation
Don't poll before blocking synchronization, and only poll once otherwise - #3360
Merged
Merged
Conversation
maleadt
added this pull request to stack #3338
October 7, 2026 11:20
Since #3315, synchronize_object queried the object before every synchronization to decide whether to collect garbage, also when synchronizing in a blocking manner, where that query costs about as much as the synchronization of an idle stream. With spinning enabled, the query was then repeated by cooperative_wait. Instead, poll once up front only when cooperative_wait would, and return right away when that finds the object done. The GC pause and draining retired resources are left for when we are actually about to wait.
maleadt
force-pushed
the
tb/sync-fastpath
branch
from
October 7, 2026 12:20
74b75db to
a581505
Compare
Contributor
CUDA.jl BenchmarksDetails
This comment was automatically generated by workflow using github-action-benchmark. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## tb/event-ownership #3360 +/- ##
======================================================
+ Coverage 84.86% 85.10% +0.23%
======================================================
Files 194 194
Lines 19960 19962 +2
======================================================
+ Hits 16939 16988 +49
+ Misses 3021 2974 -47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Since #3315,
synchronize_objectqueried the stream or event before every synchronization, only to decide whether to collect garbage. In the blocking path, that query costs about as much as synchronizing an idle stream (~350 ns on the benchmark machine). In the spinning path,cooperative_waitthen queried again. This explains thecuda/synchronization/stream/{blocking,nonblocking}regressions on the dashboard.Now the object is polled once up front, and only when
cooperative_waitwould poll it anyway (nonblocking, spinning). If it's done, we return right away, and events still go throughsynchronize_completed. The GC pause and draining of retired resources happen only when we're about to wait. Blocking andspin=falsesynchronization don't poll at all, as before #3315.Idle-GPU benchmarks (RTX 5080, Julia 1.12, 3 pinned cores, median of 3 alternating runs, ns):
The
context/autoregression on the dashboard (~1 → ~6.8 µs) is intended and not addressed here. Before #3315,device_synchronize()polled the legacy stream, which doesn't cover CUDA.jl's non-blocking task streams, and then blocked the thread incuCtxSynchronize. A context can't be polled, so it now always goes through a worker, andcontext/autocosts the same ascontext/nonblocking.