pub struct Config { /* private fields */ }Implementations§
Source§impl Config
impl Config
Sourcepub fn from_env() -> Result<Self, Error>
pub fn from_env() -> Result<Self, Error>
Creates a new default configuration and seeds it from the environment variables.
Sourcepub fn set_backend(&mut self, backend: Option<BackendKind>) -> &mut Self
pub fn set_backend(&mut self, backend: Option<BackendKind>) -> &mut Self
Forces the use of a given backend.
Default: None (automatically pick the best available backend)
Corresponding environment variable: POLKAVM_BACKEND (auto, compiler, interpreter)
Sourcepub fn backend(&self) -> Option<BackendKind>
pub fn backend(&self) -> Option<BackendKind>
Gets the currently set backend, if any.
Sourcepub fn set_sandbox(&mut self, sandbox: Option<SandboxKind>) -> &mut Self
pub fn set_sandbox(&mut self, sandbox: Option<SandboxKind>) -> &mut Self
Forces the use of a given sandbox.
Default: None (automatically pick the best available sandbox)
Corresponding environment variable: POLKAVM_SANDBOX (auto, linux, generic)
Sourcepub fn sandbox(&self) -> Option<SandboxKind>
pub fn sandbox(&self) -> Option<SandboxKind>
Gets the currently set sandbox, if any.
Sourcepub fn set_crosscheck(&mut self, value: bool) -> &mut Self
pub fn set_crosscheck(&mut self, value: bool) -> &mut Self
Enables execution cross-checking.
This will run an interpreter alongside the recompiler and cross-check their execution.
Should only be used for debugging purposes and never enabled by default in production.
Default: false
Corresponding environment variable: POLKAVM_CROSSCHECK (false, true)
Sourcepub fn crosscheck(&self) -> bool
pub fn crosscheck(&self) -> bool
Returns whether cross-checking is enabled.
Sourcepub fn set_allow_experimental(&mut self, value: bool) -> &mut Self
pub fn set_allow_experimental(&mut self, value: bool) -> &mut Self
Enabling this makes it possible to enable other experimental settings which are not meant for general use and can introduce unsafety, break determinism, or just simply be totally broken.
This should NEVER be used in production unless you know what you’re doing.
Default: false
Corresponding environment variable: POLKAVM_ALLOW_EXPERIMENTAL (true, false)
Sourcepub fn set_worker_count(&mut self, value: usize) -> &mut Self
pub fn set_worker_count(&mut self, value: usize) -> &mut Self
Sets the number of worker sandboxes that will be permanently kept alive by the engine.
This doesn’t limit the number of instances that can be instantiated at the same time; it will just tell the engine how many sandboxes should be cached between instantiations.
For the Linux sandbox this will decide how many worker processes are kept alive.
This only has an effect when using a recompiler. For the interpreter this setting will be ignored.
Default: 2
Corresponding environment variable: POLKAVM_WORKER_COUNT
Sourcepub fn worker_count(&self) -> usize
pub fn worker_count(&self) -> usize
Returns the number of worker sandboxes that will be permanently kept alive by the engine.
Sourcepub fn allow_dynamic_paging(&self) -> bool
pub fn allow_dynamic_paging(&self) -> bool
Returns whether dynamic paging is allowed.
Sourcepub fn set_allow_dynamic_paging(&mut self, value: bool) -> &mut Self
pub fn set_allow_dynamic_paging(&mut self, value: bool) -> &mut Self
Sets whether dynamic paging is allowed.
Enabling this increases the minimum system requirements of the recompiler backend:
- At least Linux 6.7 is required.
- Unpriviledged
userfaultfdmust be enabled (/proc/sys/vm/unprivileged_userfaultfdmust be set to1).
Default: false
Sourcepub fn cache_enabled(&self) -> bool
pub fn cache_enabled(&self) -> bool
Returns whether module caching is enabled.
Sourcepub fn set_cache_enabled(&mut self, value: bool) -> &mut Self
pub fn set_cache_enabled(&mut self, value: bool) -> &mut Self
Sets whether module caching is enabled.
When set to true calling Module::new or Module::from_blob
will return an already compiled module if such already exists.
Requires the module-cache compile time feature to be enabled, otherwise has no effect.
Default: true if compiled with module-cache, false otherwise
Corresponding environment variable: POLKAVM_CACHE_ENABLED
Sourcepub fn lru_cache_size(&self) -> u32
pub fn lru_cache_size(&self) -> u32
Returns the LRU cache size.
Sourcepub fn set_lru_cache_size(&mut self, value: u32) -> &mut Self
pub fn set_lru_cache_size(&mut self, value: u32) -> &mut Self
Sets the LRU cache size.
Requires the module-cache compile time feature and caching to be enabled, otherwise has no effect.
When the size of the LRU cache is non-zero then modules that are dropped will be added to the LRU cache, and will be reused if a compilation of the same program is triggered.
Default: 0
Corresponding environment variable: POLKAVM_LRU_CACHE_SIZE
Sourcepub fn set_sandboxing_enabled(&mut self, value: bool) -> &mut Self
pub fn set_sandboxing_enabled(&mut self, value: bool) -> &mut Self
Sets whether security sandboxing is enabled.
Should only be used for debugging purposes and never disabled in production.
Default: true
Corresponding environment variable: POLKAVM_SANDBOXING_ENABLED
Sourcepub fn sandboxing_enabled(&self) -> bool
pub fn sandboxing_enabled(&self) -> bool
Returns whether security sandboxing is enabled.
Sourcepub fn set_default_cost_model(
&mut self,
cost_model: Option<CostModelKind>,
) -> &mut Self
pub fn set_default_cost_model( &mut self, cost_model: Option<CostModelKind>, ) -> &mut Self
Sets the default cost model.
Default: None
Corresponding environment variable: POLKAVM_DEFAULT_COST_MODEL
Sourcepub fn default_cost_model(&self) -> Option<CostModelKind>
pub fn default_cost_model(&self) -> Option<CostModelKind>
Returns the default cost model.
Sourcepub fn imperfect_logger_filtering_workaround(&self) -> bool
pub fn imperfect_logger_filtering_workaround(&self) -> bool
Returns whether the workaround for logger filtering being imperfect is enabled.
Sourcepub fn set_imperfect_logger_filtering_workaround(
&mut self,
value: bool,
) -> &mut Self
pub fn set_imperfect_logger_filtering_workaround( &mut self, value: bool, ) -> &mut Self
Sets whether the workaround for logger filtering being imperfect is enabled
If the Log::enabled implementation of your logger can return true
regardless of the target (in other words, if it ignores the module name)
then you should enable this. Otherwise you can suffer a huge performance
hit when running the interpreter if any debug logs are enabled.
Will hard disable most of the interpreter’s debugging logs.
Default: false