Module Spoc_framework_registry.Framework_cache

val debug_enabled : bool

Enable debug logging via environment variable

val debugf : ('a, Stdlib.out_channel, unit, unit, unit, unit) Stdlib.format6 -> 'a
val warnf : ('a, Stdlib.out_channel, unit, unit, unit, unit) Stdlib.format6 -> 'a
type stats = {
  1. mutable hits : int;
    (*

    Successful cache lookups

    *)
  2. mutable misses : int;
    (*

    Failed cache lookups

    *)
  3. mutable puts : int;
    (*

    Cache writes

    *)
  4. mutable errors : int;
    (*

    I/O errors

    *)
}

Cache statistics

val stats : stats
val get_stats : unit -> stats

Get current cache statistics

val reset_stats : unit -> unit

Reset statistics

val hit_rate : unit -> float

Calculate hit rate (0.0 - 1.0)

val print_stats : unit -> unit

Print statistics to stdout

val cache_dir_name : string
val get_cache_dir : unit -> string

Get cache directory, creating it if needed

val key_schema_version : string

On-disk key schema version. Bump this whenever the key inputs change so stale entries written under an older schema can never mis-hit - they simply become unreachable orphans (safe: just re-computed and rewritten under the new key). v2 adds the kernel/entry name to the digest (v1 keys omitted it, so two kernels sharing one source string collided).

val compute_key : dev_name:string -> driver_version:string -> name:string -> source:string -> string

Compute cache key from device, driver, kernel/entry name, and source.

name (the kernel/entry-point name) must be included: a single source string may define more than one kernel, and without the name in the key a second kernel compiled from the same source would return the first kernel's cached SPIR-V. The device identity is deliberately the device NAME + driver version (not an enumeration-order ordinal) so the key stays stable across process restarts where device enumeration order is not guaranteed.

Delegates to Compile_cache.make_key for the name/source component so this on-disk cache uses the same collision-resistant, digest-per-field join as every backend's in-memory compile cache. dev_name and driver_version are digested independently before being combined into the single device component make_key expects, so a value containing ':' in either field can never shift bytes between them (the same class of bug key_schema_version concatenation used to have). The key_schema_version prefix is preserved as an outer wrapper around the digest so schema bumps still invalidate stale on-disk entries.

val get : key:string -> string option

Retrieve cached data by key

val put : key:string -> data:string -> unit

Store data in cache with given key