Skip to content

perf: reuse bounded Git object sessions #90

Description

@flyingrobots

Problem

git-cas currently starts a fresh Git process for each blob read, exact tree lookup, blob write, and tree write. The immutable caches added in v6.5.0 and v6.5.1 remove repeated work only after a cache hit; cold bounded reads and incremental materialization still pay process startup for every distinct support object.

@git-stunts/plumbing v3.2.0 now provides typed long-lived cat-file, mktree, and fast-import sessions. git-cas must own those sessions behind its persistence adapter, preserve bounded residency, and close them deterministically.

Required invariants

  • git-cas owns process reuse; callers receive no raw session or mutable Git authority.
  • Object content remains immutable by OID and ref reads remain uncached.
  • Tree-object reuse is bounded by both entry count and estimated bytes.
  • Streaming payload APIs remain streaming and do not become whole-object materialization.
  • Session failure cannot poison later operations silently.
  • Close is explicit, idempotent, waits for active operations, and releases local child processes only.
  • Adapters without the new plumbing capability retain the existing command-per-operation fallback.

Scope

  • Upgrade to @git-stunts/plumbing 3.2.0.
  • Add lazy typed session ownership to GitPersistenceAdapter.
  • Route bounded blob/object metadata reads, tree-object reads, blob writes, and tree writes through reusable protocols where lawful.
  • Add exact path lookup over bounded immutable tree objects without materializing application graphs.
  • Add ContentAddressableStore.close() and async-disposal support.
  • Publish command-count, wall-time, and bounded-memory evidence.
  • Update architecture, API, changelog, release, witness, and retro records.

Acceptance criteria

  • A cold selected bundle read uses O(1) Git child processes for session-capable object protocols rather than one process per support object.
  • Repeated exact lookups of the same immutable tree hit a count-and-byte-bounded cache.
  • Large payload restore still uses readBlobStream() and obeys existing memory limits.
  • Concurrent calls share serialized protocol sessions safely.
  • Session errors are surfaced, invalidated, and retryable through a fresh session when lawful.
  • close() is idempotent and no Git child remains after it resolves.
  • Node, Bun, and Deno tests pass.
  • Stable real-Git performance tests gate command/process regressions.
  • v6.5.2 is published to npm before git-warp adopts it.

Non-goals

  • Implementing Git object storage or packfile logic.
  • Caching refs or mutable collection metadata.
  • Moving cache ownership into git-warp.
  • Completing path-local persistent bundle derivation tracked by design: path-local persistent bundle derivation #86.
  • Replacing @git-stunts/plumbing or stock Git.

Downstream

This unblocks the git-warp v19 materialization path and its CPU plus larger-than-memory benchmark gates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:runtimeRuntime portability or public API behaviorarea:storageStorage, Git objects, manifests, or persistencestatus:in-progressActively being workedtype:designDesign doc or proof-plan worktype:goalpostRelease-scale roadmap outcometype:sliceTurn-sized proof work under a goalpost

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions