#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.window: usizePreceding pack entries inspected per object (default 16), including unsuitable entries.
max_candidates: usizeSuitable bases attempted per object (default 4).
max_object_bytes: usizeMaximum eligible base and target payload size (default 1 MiB).
max_work: u64Maximum search units per target across all candidates (default 8 million).
max_depth: usizeMaximum emitted chain depth; ordinary entries have depth zero (default 4).
min_savings: usizeMinimum complete-entry savings against ordinary encoding (default 16 bytes).
Implementations§
Source§impl DeltaOptions
impl DeltaOptions
Sourcepub fn with_window(self, window: usize) -> Self
pub fn with_window(self, window: usize) -> Self
Sets Self::window.
Sourcepub fn with_max_candidates(self, max_candidates: usize) -> Self
pub fn with_max_candidates(self, max_candidates: usize) -> Self
Sets Self::max_candidates.
Sourcepub fn with_max_object_bytes(self, max_object_bytes: usize) -> Self
pub fn with_max_object_bytes(self, max_object_bytes: usize) -> Self
Sets Self::max_object_bytes.
Sourcepub fn with_max_work(self, max_work: u64) -> Self
pub fn with_max_work(self, max_work: u64) -> Self
Sets Self::max_work.
Sourcepub fn with_max_depth(self, max_depth: usize) -> Self
pub fn with_max_depth(self, max_depth: usize) -> Self
Sets Self::max_depth.
Sourcepub fn with_min_savings(self, min_savings: usize) -> Self
pub fn with_min_savings(self, min_savings: usize) -> Self
Sets Self::min_savings.