Skip to main content

Module environment

Module environment 

Source
Expand description

Named environments: the local store everything is warmed into, one active at a time. Named environments.

An environment is one named local store: a single database holding every namespace this machine has warmed. Exactly one is active at a time, and every [Store] bound to it goes to it.

Like std, the environment is a namespace rather than a value: a set of functions over one global state, not an Environment struct to pass around. [store] creates stores in it, bundle captures it for shipping, and [activate]/[set_root]/[load] switch it.

Naming them makes it possible to keep several side by side, which is what you want when the same checkout targets more than one machine or you want a throwaway environment for an experiment:

cubecl_environment::environment::activate("h100");

Switching is dynamic: every store bound to the environment detects the switch and resets — the in-memory cache is dropped and the storage is reopened against the new environment. Detection is one atomic load on the store’s read path, so an environment that never switches costs nothing.

Re-exports§

pub use crate::persistence::CacheOption;
pub use crate::persistence::Namespace;
pub use crate::persistence::Store;
pub use crate::persistence::StoreOptions;

Constants§

DEFAULT
The environment used when none is chosen.
EXTENSION
The extension of an environment’s database file.

Functions§

activate
Makes name the active environment.
active
The active environment.
file_name
The file name holding the active environment inside a cache root.
generation
An opaque token that changes on every environment switch.
list
Every environment that exists, sorted by name.
load
Mounts the database at file as the active environment.
namespaces
What the active environment currently holds, one row per namespace.
path
The database file of the active environment: the file mounted by load, or <root>/<name>.db.
root
The directory environments are kept in, defaulting to the standard cache root.
set_root
Sets the directory environments are kept in.
store
A Store created from the options, bound to the active environment whenever the options name a storage.