Skip to main content

DeltaOptions

Struct DeltaOptions 

Source
#[non_exhaustive]
pub struct DeltaOptions { pub window: usize, pub max_candidates: usize, pub max_object_bytes: usize, pub max_work: u64, pub max_depth: usize, pub min_savings: usize, }
Expand description

Bounds and selection policy for internal REF_DELTA entries.

Pack and index order remain ascending object ID. Search visits the preceding window entries newest first, trying at most max_candidates of the same kind, with lengths within a factor of two and within max_object_bytes. Bases always precede dependents; no external bases or OFS_DELTA offsets are emitted. REF_DELTA needs no delta-specific receive-pack capability; the transport must still negotiate the repository object format independently.

A fixed 4096-slot table indexes 8-byte anchors every 16 base bytes; the earliest anchor wins a hash collision. Target scanning and match extension consume max_work units per object across all candidates. Exhaustion discards the unfinished candidate and keeps the best completed entry. One unit means one indexed anchor, scanned target position, or compared byte. Hashing an anchor reads eight bytes. This is a deterministic algorithmic budget, not a CPU or wall-clock limit. Each completed candidate additionally compresses at most roughly 2 * max_object_bytes + 20 instruction bytes. Identity hashing and ordinary compression retain the pack input bounds.

Selection compares complete entry headers, the format-sized base ID, and zlib bytes. A delta must save at least min_savings bytes against the ordinary entry and strictly beat the current best; ties retain the first candidate. Search is skipped when mandatory header/base-ID overhead already rules out sufficient savings. The default saves at least 16 bytes. Output is reproducible for fixed inputs, options, and compression backend/version, independent of caller order.

Payloads are borrowed. Additional live scratch is bounded by a 32 KiB anchor table and roughly eight times max_object_bytes, plus zlib scratch and allocator overhead. Entry metadata is proportional to input count. These are not total-process heap bounds. Objects larger than the configured size (or u32::MAX) use the streaming ordinary path. Zero bounds disable search; no option value is invalid. Small objects under eight bytes also use ordinary entries.

Tune search effort independently of the pack input bounds. Exhaustion falls back to the best completed encoding; it does not authorize an incomplete pack or weaken identity verification.

use girt::{
    DeltaOptions, ObjectFormat, ObjectId, ObjectKind, PackCompression, PackObject,
    PackWriteLimits, write_pack_with_compression,
};

let (mut pack, mut index) = (Vec::new(), Vec::new());
// These related payloads can delta, but this policy allows no search work.
let policy = PackCompression::Delta(DeltaOptions::default().with_max_work(0));
let report = write_pack_with_compression(
    ObjectFormat::Sha1,
    &inputs,
    &mut pack,
    &mut index,
    PackWriteLimits::default(),
    policy,
)?;
assert_eq!(report.objects, 2);

assert_eq!(report.deltas.entries, 0);
assert_eq!(report.deltas.work, 0);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§window: usize

Preceding pack entries inspected per object (default 16), including unsuitable entries.

§max_candidates: usize

Suitable bases attempted per object (default 4).

§max_object_bytes: usize

Maximum eligible base and target payload size (default 1 MiB).

§max_work: u64

Maximum search units per target across all candidates (default 8 million).

§max_depth: usize

Maximum emitted chain depth; ordinary entries have depth zero (default 4).

§min_savings: usize

Minimum complete-entry savings against ordinary encoding (default 16 bytes).

Implementations§

Source§

impl DeltaOptions

Source

pub fn with_window(self, window: usize) -> Self

Source

pub fn with_max_candidates(self, max_candidates: usize) -> Self

Source

pub fn with_max_object_bytes(self, max_object_bytes: usize) -> Self

Source

pub fn with_max_work(self, max_work: u64) -> Self

Source

pub fn with_max_depth(self, max_depth: usize) -> Self

Source

pub fn with_min_savings(self, min_savings: usize) -> Self

Trait Implementations§

Source§

impl Clone for DeltaOptions

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 DeltaOptions

Source§

impl Debug for DeltaOptions

Source§

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

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

impl Default for DeltaOptions

Source§

fn default() -> Self

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

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more