incremental-cache
only.Expand description
This module provides a set of primitives that allow implementing an incremental cache on top of Cranelift, making it possible to reuse previous compiled artifacts for functions that have been compiled previously.
This set of operation is experimental and can be enabled using the Cargo feature
incremental-cache
.
This can bring speedups in different cases: change-code-and-immediately-recompile iterations get faster, modules sharing lots of code can reuse each other’s artifacts, etc.
The three main primitives are the following:
compute_cache_key
is used to compute the cache key associated to aFunction
. This is basically the content of the function, modulo a few things the caching system is resilient to.serialize_compiled
is used to serialize the result of a compilation, so it can be reused later on by…try_finish_recompile
, which reads binary blobs serialized withserialize_compiled
, re-creating the compilation artifact from those.
The CacheStore
trait and Context::compile_with_cache
method are provided as
high-level, easy-to-use facilities to make use of that cache, and show an example of how to use
the above three primitives to form a full incremental caching system.
Structs§
- Cache
KeyHash - Hashed
CachedKey
, to use as an identifier when looking up whether a function has already been compiled or not.
Enums§
- Recompile
Error - An error returned when recompiling failed.
Traits§
- Cache
KvStore - Backing storage for an incremental compilation cache, when enabled.
Functions§
- compute_
cache_ key - Compute a cache key, and hash it on your behalf.
- serialize_
compiled - Given a function that’s been successfully compiled, serialize it to a blob that the caller may
store somewhere for future use by
try_finish_recompile
. - try_
finish_ recompile - Given a function that’s been precompiled and its entry in the caching storage, try to shortcut compilation of the given function.