Commit 40d93c4
committed
feat(core.utils): add persistent program caches (sqlite + filestream)
Convert ``cuda.core.utils`` to a package and add persistent, on-disk
caches for compiled ``ObjectCode`` produced by ``Program.compile``:
* ``ProgramCacheResource`` — abstract Mapping-like base class with a
context manager, ``get``/``close``, and a ``pickle``-safety warning.
* ``SQLiteProgramCache`` — single-file sqlite3 backend (WAL mode,
autocommit) with LRU eviction against an optional size cap.
* ``FileStreamProgramCache`` — directory of atomically-written entries
(staged tmp file + ``os.replace``) for concurrent multi-process use,
with best-effort size enforcement by mtime. Windows ``PermissionError``
from ``os.replace`` is treated as a non-fatal cache miss.
* ``make_program_cache_key`` — stable 32-byte blake2b key derived from
code, code_type, ProgramOptions, target_type, name expressions, cuda
core/driver/NVRTC versions, and NVVM-specific fields (``extra_sources``,
``use_libdevice``) that would otherwise collide.
``sqlite3`` is imported lazily so the rest of the package is usable on
interpreters built without libsqlite3.
Includes single-process CRUD, LRU/size-cap, corruption-handling, and
multiprocess stress tests, plus an end-to-end test that compiles a real
CUDA C++ kernel, stores it in each backend, reopens the cache, and
verifies ``get_kernel`` still works on the deserialised ``ObjectCode``.
Public API is documented in ``cuda_core/docs/source/api.rst``.1 parent 56b53ca commit 40d93c4
File tree
6 files changed
+1543
-8
lines changed- cuda_core
- cuda/core
- utils
- docs/source
- tests
6 files changed
+1543
-8
lines changedThis file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments