#[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
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
impl ParallelDecode
Sourcepub const DEFAULT_BYTES: NonZeroU64
pub const DEFAULT_BYTES: NonZeroU64
Default lookahead: 128 MiB.
Sourcepub const fn lookahead(self) -> Option<NonZeroU64>
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
impl Clone for ParallelDecode
impl Copy for ParallelDecode
Source§impl Debug for ParallelDecode
impl Debug for ParallelDecode
Source§impl Default for ParallelDecode
impl Default for ParallelDecode
impl Eq for ParallelDecode
Source§impl From<Option<NonZero<u64>>> for ParallelDecode
impl From<Option<NonZero<u64>>> for ParallelDecode
Source§fn from(lookahead: Option<NonZeroU64>) -> Self
fn from(lookahead: Option<NonZeroU64>) -> Self
None is ParallelDecode::Sequential.
Source§impl PartialEq for ParallelDecode
impl PartialEq for ParallelDecode
impl StructuralPartialEq for ParallelDecode
Auto Trait Implementations§
impl Freeze for ParallelDecode
impl RefUnwindSafe for ParallelDecode
impl Send for ParallelDecode
impl Sync for ParallelDecode
impl Unpin for ParallelDecode
impl UnsafeUnpin for ParallelDecode
impl UnwindSafe for ParallelDecode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.