Skip to main content

EntryBytes

Enum EntryBytes 

Source
pub enum EntryBytes {
    Extent {
        offset: u64,
        len: u64,
    },
    Owned(Vec<u8>),
}
Expand description

Where an entry’s bytes are — an address into the archive, or bytes that exist nowhere else.

§Why this is not a Vec<u8>

It was one until 2026-08-14, and that single field is what made a clone hold the whole repository. crate::git_ops::GitStore::emit_set filled it with a pread into a fresh Vec::with_capacity(len) — one syscall, one allocation and one kernel→user copy per object — and every one of those Vecs was live at once, because the entries are all built before emit_pack writes a byte. On a linux.git clone: ~13.8 M syscalls, ~27.6 M allocations, 6.4 GB copied and held, and a peak RSS of 2314 MB against gitea’s 122 MB on the identical clone (gunnar/.nornir/forge-bakeoff-benchmarks.md, vs_forge_clone).

An Extent is 16 bytes and addresses bytes that are already in the page cache. Resolving it is [crate::archive_map::Mapped::get] — pointer arithmetic and a bounds check — with a pread fallback for the one case a mapping cannot answer.

Variants§

§

Extent

The stored entry exactly as received, addressed in the archive’s coordinate space. Header and all: offset is the entry’s type/size varint and len runs to where the next entry starts.

This is what a full clone is made of, end to end. Nothing copies it until emit_pack writes it to the wire.

Fields

§offset: u64
§len: u64
§

Owned(Vec<u8>)

The exception: bytes that are on no disk.

Three shapes reach here, and every one of them genuinely computed bytes that no extent addresses:

  • a delta whose base the request does not carry, rebuilt whole or re-deltified against a base it does carry ([Self::recompressed] — crate::delta);
  • an OFS_DELTA re-headed as a REF_DELTA for a client with no ofs-delta capability, or for a thin fetch — the payload is a copy but the header in front of it is new, so the concatenation is new;
  • a fixture built by hand in a test.

It is zero for a whole-repository clone, which is the measurement the extent form exists to make true rather than a promise this makes.

Implementations§

Source§

impl EntryBytes

Source

pub fn len(&self) -> u64

How many bytes this entry contributes, without resolving it.

Free for an Extent — the length is the address — which is what lets a caller size or account for a pack it has not read.

Source

pub fn is_empty(&self) -> bool

Whether this entry contributes nothing. Only a hand-built fixture can.

Source

pub fn owned(&self) -> Option<&[u8]>

The bytes, when this entry carries them itself. None for an extent, which has to be resolved against the archive.

Trait Implementations§

Source§

impl Clone for EntryBytes

Source§

fn clone(&self) -> EntryBytes

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 Debug for EntryBytes

Source§

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

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

impl Eq for EntryBytes

Source§

impl PartialEq for EntryBytes

Source§

fn eq(&self, other: &EntryBytes) -> 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 EntryBytes

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = 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.