Skip to main content

ParallelDecode

Enum ParallelDecode 

Source
#[non_exhaustive]
pub enum ParallelDecode { Sequential, Bounded(NonZeroU64), }
Expand description

How much extra memory a 7z block may use to decode LZMA2 runs ahead on worker threads.

An LZMA2 stream written with multiple threads (7-Zip’s default for large inputs) consists of independent runs, so several can be decoded at once. Decoded runs wait in memory until the consumer reaches them, so the lookahead is bounded: Bounded(n) lets in-flight runs hold at most n bytes on top of the decoder window that max_decoder_memory already admits. Sequential decodes on the calling thread only.

Archives written with runs of a few MiB decode within about 10% of an unbounded multi-threaded reader at the default; a stock 7-Zip archive has 64 MiB runs and needs about 100 MiB of lookahead per extra concurrent run.

A valid archive decodes to the same bytes in either mode, and a corrupt one fails the same file with the same error kind; only how many leading bytes that file received can differ.

§Concurrency

The limit applies to one extraction or verification. Each call may start up to 16 worker threads and hold its own lookahead, so concurrent calls (for example from several Python threads or Node promises) multiply both the threads and the memory. Size the setting for the number of calls that can run at once, or use Sequential.

§Examples

use std::num::NonZeroU64;

use exarch_core::ParallelDecode;
use exarch_core::SecurityConfig;

assert_eq!(
    SecurityConfig::default().parallel_decode,
    ParallelDecode::Bounded(NonZeroU64::new(128 * 1024 * 1024).unwrap())
);
let config = SecurityConfig::default().with_parallel_decode(ParallelDecode::Sequential);
assert_eq!(config.parallel_decode, ParallelDecode::Sequential);

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Sequential

Decode on the calling thread only

§

Bounded(NonZeroU64)

Decode runs ahead on worker threads, holding at most this many bytes

Implementations§

Source§

impl ParallelDecode

Source

pub const DEFAULT_BYTES: NonZeroU64

Default lookahead: 128 MiB.

Source

pub const fn lookahead(self) -> Option<NonZeroU64>

The lookahead memory in bytes, or None for Sequential.

§Examples
use std::num::NonZeroU64;

use exarch_core::ParallelDecode;

assert_eq!(ParallelDecode::Sequential.lookahead(), None);
let bytes = NonZeroU64::new(1 << 20).unwrap();
assert_eq!(ParallelDecode::Bounded(bytes).lookahead(), Some(bytes));

Trait Implementations§

Source§

impl Clone for ParallelDecode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ParallelDecode

Source§

impl Debug for ParallelDecode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ParallelDecode

Source§

fn default() -> Self

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

impl Eq for ParallelDecode

Source§

impl From<Option<NonZero<u64>>> for ParallelDecode

Source§

fn from(lookahead: Option<NonZeroU64>) -> Self

Source§

impl PartialEq for ParallelDecode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ParallelDecode

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.