cuda.core.utils.FileStreamProgramCache#
- class cuda.core.utils.FileStreamProgramCache( )#
Persistent program cache backed by a directory of atomic files.
Designed for multi-process use: writes stage a temporary file and then
os.replace()it into place, so concurrent readers never observe a partially-written entry. There is no cross-process LRU tracking; size enforcement is best-effort by file mtime.Note
Best-effort writes.
On Windows,
os.replaceraisesPermissionError(winerror 32 / 33) when another process holds the target file open. This backend retries with bounded backoff (~185 ms) and, if still failing, drops the cache write silently and returns success-shaped control flow. The next call will see no entry and recompile. POSIX and otherPermissionErrorcodes propagate.Note
Atomic for readers, not crash-durable.
Each entry’s temp file is
fsync-ed beforeos.replace, but the containing directory is notfsync-ed. A host crash between write and the next directory commit may lose recently added entries; surviving entries remain consistent.Note
Cross-version sharing.
_FILESTREAM_SCHEMA_VERSIONguards on-disk format changes: a cache written by an incompatible version is wiped on open. Within a single schema version, the cache is safe to share acrosscuda.corepatch releases because every entry’s key encodes the relevant backend/compiler/runtime fingerprints for its compilation path (NVRTC entries pin the NVRTC version, NVVM entries pin the libNVVM library and IR versions, PTX/linker entries pin the chosen linker backend and its version – and, when the cuLink/driver backend is selected, the driver version too; nvJitLink-backed PTX entries are deliberately driver-version independent).- Parameters:
path – Directory that owns the cache. Created if missing.
max_size_bytes – Optional soft cap on total on-disk size. Enforced opportunistically on writes; concurrent writers may briefly exceed it.
Methods
- get(
- key: bytes | str,
- default: ObjectCode | None = None,
Return
self[key]ordefaultif absent.