Skip to content

test(cuda-host,finalizer): replace timed contention and release with handshakes - #1716

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:test/deterministic-cache-and-etxtbsy-tests
Nov 9, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
vyncint:test/deterministic-cache-and-etxtbsy-tests

Conversation

@vyncint

@vyncint vyncint commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What This PR Does

Replaces fixed 30ms thread::sleep delays with deterministic synchronization in two concurrency/retry unit tests:

  1. ETXTBSY Version-Probe Retry Test (cuda-artifact-finalizer)
  2. Single-Flight LTOIR Cache Lock Test (cuda-host)

1. Deterministic Retry & Lock Contention Hooks

Previously, both tests slept for 30ms to approximate thread ordering, which could either fail spuriously on loaded runners or pass without exercising the retry/lock path:

BEFORE:
  ptx.rs:         background thread sleeps 30ms, then drops write fd
  ltoir_cache.rs: winner sleeps 30ms hoping 7 other threads contend on lock

AFTER:
  ptx.rs:         `BUSY_RETRY_WAIT` hook drops write fd inside retry #1
                  (plus a second test asserting all 8 doubling delays: 2ms..256ms)
  ltoir_cache.rs: `KEY_LOCK_ARRIVALS` condvar holds the build until all 8 threads
                  reach `acquire_key_lock`
  • Guarantees that PtxAssembler::from_path observes ExecutableFileBusy at least once before succeeding.
  • Guarantees that all 8 threads miss the cache fast path and contend on the per-key lockfile before the build publishes.

Verification

  • Tests & CI Gates:
    • cargo test -p cuda-artifact-finalizer -p cuda-host --lib: PASS
    • cargo clippy -p cuda-artifact-finalizer -p cuda-host --all-targets -- -D warnings: PASS
    • cargo oxide fmt --check: PASS

Part of #1680

…handshakes

Two CPU tests stood a fixed 30 ms delay in for an ordering they could
not observe.

The ETXTBSY test released the fake ptxas's write descriptor from another
thread after 30 ms. A late release past the ~510 ms retry budget failed
it spuriously, and a first exec after the release passed it without
exercising the retry. The retry delay now goes through
`wait_before_busy_retry`, which a `#[cfg(test)]` thread-local closure can
replace. The version probe runs on the caller's thread, so the test can
release the descriptor from inside the first retry, proving through
`PtxAssembler::from_path` that a real "Text file busy" was hit and ridden
out. A second test keeps the descriptor open and asserts the probe still
fails with ETXTBSY after exactly the eight doubling delays.

The LTOIR cache single-flight test slept 30 ms in the build to encourage
the other threads to contend. A thread arriving after publication took
the fast path instead, so the test could not tell a working lock from a
missing one. `acquire_key_lock` now records each arrival under
`#[cfg(test)]`, and the build waits on a condvar until all eight threads
have reached the lock, with a watchdog that fails with the count.

Both were checked against broken implementations: no retry, nine
retries, no re-check after the lock, and no lock all fail.

Part of NVIDIA#1680.

Signed-off-by: Vyncint Ng <[email protected]>
@vyncint
vyncint requested a review from nihalpasham as a code owner November 3, 2026 13:06
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nihalpasham nihalpasham added cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book tests Adds or improves test coverage host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) labels Nov 9, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

/ok to test 8af55a7

@nihalpasham

Copy link
Copy Markdown
Collaborator

Thanks, replacing the 30ms sleeps with deterministic retry and lock-arrival hooks removes the timing races and verifies the 8-step ETXTBSY backoff schedule directly.

At 8af55a77, cargo test and cargo clippy for cuda-artifact-finalizer and cuda-host pass. Merging once CI is green.

@nihalpasham
nihalpasham merged commit 867a6ac into NVIDIA:main Nov 9, 2026
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book host-apis Host-side runtime APIs (cuda-host, cuda-core, cuda-async) tests Adds or improves test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants