Re: [PATCH v2 00/13] odb: stop registering in-memory sources
From: Karthik Nayak <hidden>
Date: 2026-09-04 22:45:59
Patrick Steinhardt [off-list ref] writes:
Hi,
the object database has a list of sources that is used for two
different purposes:
- We use it to track the list of alternates.
- We use it to track temporary in-memory sources that we create for
various purposes. Most importantly, this is used to link object
database sources from submodules into the main store.
This dual-use is quite awkward, as it mixes two different levels of
concerns and thus as a consequence makes both harder to reason about.
It's also a source of bugs: we make assumptions about the ordering of
sources all over the place, and we furthermore assume in other places
that the sources only contain alternates in the first place. I don't
think this surfaces in the form of real bugs, but I've long disliked
this dual-use.
Furthermore, we want to migrate handling of alternates into the "files"
backend itself in a subsequent patch series. This is most importantly to
fix a performance regression by making the backend own all of its
alternates, but it also fixes a couple of longer-standing design issues
that I've been struggling with [1].
Most importantly though: this whole machinery is not even needed at all.
A couple years ago we have already refactored our codebase so that
submodule sources don't even have to be linked into the main object
database anymore. And all the other use cases where we link sources into
the main object database can be trivially converted, too.
So this patch series does exactly that: it removes the mechanism to link
ad-hoc sources into the object database entirely. This ensures that the
list of sources is exactly the list of alternates, and that makes it
easier to move them into the "files" backend in a subsequent patch
series.
There is one exception though: creating transactions still creates a
temporary quarantine directory. This mechanism is left as-is for now,
but as it's an implementation detail of the "files" backend anyway
that's not conflicting with our above stated goals.
This series is built on top of 1630431f32 (The 21st batch, 2026-08-31)
with ty/repository-fetch-if-missing at 508ec9837c (repository: move
fetch_if_missing into struct repository, 2026-08-15) merged into it.
There's still two merge conflicts, but these are trivial to resolve: in
"odb.c" and "odb.h" you simply remove both ours and theirs, and in
"builtin/multi-pack-index.c" you only need to munge the parameters a
bit.This was a bit of a dense read for me, mostly as I'm not too familiar with the code here. So I can not so confidently say that the series looks good :)
Changes in v2:
- Adapt `cache_tree_fully_valid()` to take a `struct index_state` as
input instead of taking both a repository and a cache tree, as
suggested by Junio.
- Link to v1: https://patch.msgid.link/20260901-pks-odb-registering-in-memory-sources-v1-0-97a312d5fa25@pks.im
Thanks!
Patrick[snip]
Attachments
- signature.asc [application/pgp-signature] 690 bytes