Config

Struct Config 

Source
pub struct Config { /* private fields */ }

Implementations§

Source§

impl Config

Source

pub fn new() -> Self

Creates a new default configuration.

Source

pub fn from_env() -> Result<Self, Error>

Creates a new default configuration and seeds it from the environment variables.

Source

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)

Source

pub fn backend(&self) -> Option<BackendKind>

Gets the currently set backend, if any.

Source

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)

Source

pub fn sandbox(&self) -> Option<SandboxKind>

Gets the currently set sandbox, if any.

Source

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)

Source

pub fn crosscheck(&self) -> bool

Returns whether cross-checking is enabled.

Source

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)

Source

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

Source

pub fn worker_count(&self) -> usize

Returns the number of worker sandboxes that will be permanently kept alive by the engine.

Source

pub fn allow_dynamic_paging(&self) -> bool

Returns whether dynamic paging is allowed.

Source

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 userfaultfd must be enabled (/proc/sys/vm/unprivileged_userfaultfd must be set to 1).

Default: false

Source

pub fn cache_enabled(&self) -> bool

Returns whether module caching is enabled.

Source

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

Source

pub fn lru_cache_size(&self) -> u32

Returns the LRU cache size.

Source

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

Source

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

Source

pub fn sandboxing_enabled(&self) -> bool

Returns whether security sandboxing is enabled.

Source

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

Source

pub fn default_cost_model(&self) -> Option<CostModelKind>

Returns the default cost model.

Source

pub fn imperfect_logger_filtering_workaround(&self) -> bool

Returns whether the workaround for logger filtering being imperfect is enabled.

Source

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

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.