Skip to main content

Module serve

Module serve 

Source
Expand description

GitServe — the reading contract: decoded reads, the HEAD accessor pair, negotiation and pack emission. Layered above git_ops, answered out of Arrow IPC, and containing no gix — see the module header for why that is a rule rather than a coincidence. The reading contract, answered out of Arrow IPC. No gix, anywhere.

ZNIPPY-GIT APACHE ARROW IPC IS LAW. crate::store holds the eleven — what a caller stores; this file holds GitServe — what a caller reads, and what a clone is served from. The split is the contract’s, not this crate’s: GitOps::get hands back the pack entry byte for byte as the client sent it, which for a delta is a delta, and nothing on the eleven inflates one.

  read / header / sizes        →  the objects table, then §14's exploded table
  head / set_head              →  the ref log; HEAD is NOT a row in refs()
  select                       →  roaring bitmaps over the store's ordinals
  emit_pack                    →  emit_set → topological_order → byte-range copy

§🚨 The trap this file exists to avoid, stated once

The working reference for every method below is gunnar-coldtier’s git_store.rs, and it carries 87 gix_ references. It reads objects through gix_pack::Find / decode_entry / decode_header, and it emits packs through iter_from_counts / InOrderIter / FromEntriesIter. Its intent is ported here. Not one line of its code is.

znippy-plugin-git links zero gix in [dependencies] — the four gix crates it names are [dev-dependencies], the differential oracle in crate::pack_walk that proves this crate’s parser agrees with gitoxide without shipping it. That separation is the entire point of two implementations behind one contract, and no method here may create an edge into it. Not for a parser, not for gix-hash, not temporarily.

Nor would copying it be desirable. That pack pipeline is P-018’s serial tail — counting’s serial reduce, a sort_by over counts, InOrderIter’s BTreeMap reorder, FromEntriesIter hashing every byte on the consuming thread — plus P-025’s residue, data.to_owned(), one heap allocation per object served. The Arrow arm’s answer to all of it is a byte-range copy out of the archive, and crate::pack_walk::emit_pack is where it lives.

§The serving tier is serial — P-004, DECIDED, with one bounded exception

sizes does not fan out. select does not fan out. The two-tier split is settled: request concurrency, no intra-request fan-out, one core’s worth per transfer behind an admission gate. At saturation, parallelising one clone across N cores does not raise clones per second — it is the same work rearranged — and the constellation’s fan-out primitive has no reentrancy detection, so a fan-out here inside a fan-out there silently spawns W². gatling belongs in crate::indexer’s background tier, which is where nearly all of it is.

The exception, added 2026-08-14, is phase 1 of emit_oidsGitStore::resolve_emit_payloads, which turns each entry’s archive address into a slice of the mapped archive. It is allowed for the reason the decision above is stated in terms of and not against it:

  • it is bounded at 4 workers, not at ncores, so 32 admitted transfers are 128 threads at worst rather than 32 × ncores — the admission gate stays in charge of the machine;
  • it does not run at all below 4096 entries, so every request small enough for thread-spawn to dominate is byte for byte the old serial path;
  • it takes no lock, because the archive is append-only and immutable behind a snapshot, so it is not the “same work rearranged” — it is work that has no serial dependency to rearrange around.

Phase 2 — output offsets, OFS_DELTA distances, the writes and the running hash — stays strictly serial, and that is not a bound anyone chose: an OFS_DELTA names its base by distance back in the output pack, so entry n cannot be encoded until every earlier entry’s length is known.

Every method blocks. Never call one from an async task without tokio::task::spawn_blocking.

Structs§

Caps
What the client said it can parse, as far as pack emission is concerned.
PackStats
The receipt for one GitServe::emit_pack.
ReachSet
One GitServe::select answer.

Constants§

HEAD
HEAD, the one pseudo-ref this contract names.

Traits§

GitServe
The READING contract.