Repository navigation
A mirror fetch keeps what it receives as a pack, so shared checkouts see it - #1705
Conversation
…see it Git stores a fetch of fewer than fetch.unpackLimit objects (100 by default) as loose objects. A compiler-tier checkout links only the mirror's packs, so the objects of such a fetch were missing from it. The checkout's own fetch then found the target incomplete and had the mirror send it again; a checkout with no ref yet received the mirror's whole history. Mirror fetches now run with fetch.unpackLimit=1, so every fetch writes a pack that the next tier pass links. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
…tes a pack With every fetch writing a pack, a mirror between two weekly gcs could gather thousands of packs, and a shared checkout's sandboxed job mounts each one. Past 50 packs a gc may rewrite (git's gc.autoPackLimit), gc_if_due now runs a geometric repack, which merges the small packs and leaves the large one. A clone from a local path copied the source's loose objects as they were; it now runs with --no-local, so the mirror starts as a pack. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
Each repack makes every shared checkout of the mirror run a full gc, and the sandbox's bind list overflows only at a few thousand packs, so the trigger sits well above git's own limit of 50. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
The new repack path needs the disk-space guard used by scheduled GC. A busy mirror can reach the pack limit while the volume is already below its reserve.
The repack writes its new pack beside the old ones, so on a volume already below the gc margin it could use up the space ingest needs. It now takes the same free space check as the gc and is skipped, with a warning, when there is no room; the next round tries again. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
The format job fails on the adoption page with the same formatter output on clean |
|
The repack now takes the guard scheduled gc uses, so a mirror without room keeps its packs and waits. The change is in 13f7cf0, with the Mirror housekeeping paragraph updated to say so. |
zlareb1
left a comment
There was a problem hiding this comment.
The repack uses the same disk headroom check as scheduled GC. The low-space probe leaves the pack set and GC mark alone. With sufficient space, the repack starts. The checkout transfer test also passes on the merged tree.
zlareb1
left a comment
There was a problem hiding this comment.
The completed unit job reports a new tunable-constant failure for the repack threshold. The disk-space finding is fixed. This review supersedes my earlier approval of this head.
|
FYI, the git repack job is largely overestimating the needed spaces. My agents have implement accurate estimation, but I asked them to base the loom logic on the stock repack space estimate. Do you think it's worth to base the logic on an accurate size ETA, or the stock double + margin is fine? |
zlareb1
left a comment
There was a problem hiding this comment.
The rename integration test returns about_naming on this head and on its CI base. The fixture describes a naming claim. Repair #1719 changes it to describe runtime behavior, and the same assertion passes. PR job · Main job · Repair #1719
The pack count past which gc_if_due runs a geometric repack was a module constant, which test_no_new_tunable_constant rejects. It becomes code_mirror_gc_pack_limit, default 500, beside the other mirror gc settings. The tests that lowered the constant set the setting instead. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
The tunable-constant check reports the same duplicate coverage limit on this head and on clean main. The coverage repair moves the bound report to the store. The same check passes on main with both the coverage and docstring repairs applied. PR job · Main job · Coverage repair #1722 · Docstring repair #1706
Loom's mirror clone writes gc.auto=0 and maintenance.auto=false, but the _packed_bare fixture cloned with git's defaults. Under git 2.56 the automatic maintenance repacked that mirror between the fetches, so the checkout transfer test received objects and failed on every run. The fixture now clones with the same two settings, and the operations page names LOOM_CODE_MIRROR_GC_PACK_LIMIT where it described the threshold. Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
|
The tunable-constant failure is fixed by the setting |
zlareb1
left a comment
There was a problem hiding this comment.
The settings catalog now supplies the pack threshold, and the generated defaults match. The pack-limit and low-disk tests pass. I also checked that the mirror fetch and checkout paths preserve the shared-pack behavior.
Closes: #1702
Related: #1553
TL;DR: The mirror's fetches run with
fetch.unpackLimit=1and its clone with--no-local, so everything the mirror receives is in a pack that a shared compiler-tier checkout links on its next pass; pastcode_mirror_gc_pack_limitpacks (500 by default),gc_if_dueruns a geometric repack, when the disk has the room its gc needs. Before, a fetch of fewer than 100 objects stayed loose in the mirror, out of the checkout's sight, and the checkout's fetch had the mirror send the target's history again.Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
With
LOOM_CODE_COMPILER_SHARE_MIRROR_PACKSon, a commit the mirror fetched in a small fetch no longer makes a compiler-tier checkout fetch the repository's history again: the mirror keeps every fetch as a pack, which the checkout shares.Why
_share_mirror_packshard-links the mirror's packs into each checkout and nothing else. Git stores a fetch of fewer thanfetch.unpackLimitobjects (100 by default) as loose objects, so the usual one-commit fetch of the mirror stayed out of every checkout until the mirror's gc packed it. The checkout's fetch (checkout_fetch_args) then found the target's closure incomplete and fetched it from the mirror; a checkout with no ref yet had nothing to negotiate from and received the mirror's whole history as a pack of its own.gitrepo._network_git, the runner of every fetch into the mirror (fetch,fetch_many,fetch_branches,fetch_shas,fetch_pull_heads), addsfetch.unpackLimit=1to the job's git config, so each of them writes a pack. A clone from a local path copied the source's loose objects as they were;clone_mirrornow passes--no-local, which makes git pack them.One pack per fetch adds up between two weekly gcs, and a shared checkout's sandboxed job mounts every pack it links (one
--ro-bindper file), so thousands of packs would push bwrap's argv past the kernel's limit.gc_if_duetherefore also runsgit repack -d -l --geometric=2when a mirror or checkout holds more than 500 packs a gc may rewrite (code_mirror_gc_pack_limit, default 500), and only under the free-space check the gc has: the repack writes its pack beside the old ones, so when free space is below what a gc would rewrite pluscode_mirror_gc_margin_gb, it is skipped with the gc's warning and tried again on the next round. The check asks for the worst case, a rewrite of the whole set; a volume that cannot hold that needs more space. In the mirror it merges the small packs and leaves the large one. The limit sits well below the few thousand packs at which the bind list overflows, and well above git's own 50, because of the checkout cost below.Measured on a public repository (one 17 GB pack, 3.9 million objects, git 2.43.7), a new shared checkout's fetch of the mirror's head, timed with
GIT_TRACE2_PERF:rev-list --objects --not --all(connectivity walk)main(3 loose objects)pack-objects746 s (enumerate-objects404 s,write-pack-file342 s),index-pack705 s, then the walk 469 sEach arm is a new checkout from
resolve_checkoutwith sharing on, thenGIT_TRACE2_PERF=<file> git -C <checkout> fetchwithcheckout_fetch_args(<mirror>, <head>)underauth_env. The middle arm's commit reached the mirror throughgit -c fetch.unpackLimit=1 fetch, the last one's through a plaingit fetch.Scope and risk
ls-remote, which ignores it. The checkouts' own fetches are unchanged.pack-objectsin the source,index-packin the mirror) instead of copying files, so it takes longer on a large repository: 5.6 s instead of 0.0 s for a 127k-object repository. Local-path remotes are meant for tests and small mirrors; a clone over the network already wrote a pack.gc --no-prunestill merges everything into one pack. Nothing prunes.gc --no-prune: a walk of every reachable object that rewrites almost nothing (0.6 s on a 127k-object repository; a history walk took 406 to 534 s on the 3.9-million-object one in the table). That gc ran once a week before; now it also runs after each repack, about once per 500 mirror fetches.docs/operations/code-index-operations.md: the shared-packs paragraph says the mirror's clone and fetches write packs, and Mirror housekeeping names the repack.rev-list --objects --not --allwith no ref to stop at, 406 to 534 s in the table), on a packed mirror too; that is a separate cause, left for its own change.Compatibility, rollout and rollback
LOOM_CODE_MIRROR_GC_PACK_LIMIT, default 500, the old constant's value; no default of an existing setting changes.Tests
tests/unit/test_code_compiler_checkout.py::test_a_small_mirror_fetch_keeps_its_objects_in_a_pack(red): one commit fetched into a packed mirror throughgitrepo.fetchwith real git leaves no loose object. Onmainit fails withassert 3 == 0.tests/unit/test_code_compiler_checkout.py::test_a_checkout_fetch_after_small_and_large_mirror_fetches_transfers_nothing(red): a shared checkout's first pass, a one-commit mirror fetch, a 150-file mirror fetch, then a second pass withresolve_checkoutand the tier's fetch and checkout. It expects no object file of the checkout's own,git rev-list --objectsof the target to succeed, and both new files in the working tree; the test mirror is cloned with Loom'sgc.auto=0andmaintenance.auto=false, so git's own maintenance does not repack it. Onmainthe checkout's fetch writes a pack of its own and the first assertion fails.tests/unit/test_mirrors.py::test_more_packs_than_the_limit_are_merged_before_the_gc_is_due(red): 55 one-commit fetches give a mirror 56 packs the day after its gc; withcode_mirror_gc_pack_limitset to 50 for the test,gc_if_dueleaves at most 2, and every object stays reachable. Onmainthe 56 packs stay.tests/unit/test_mirrors.py::test_the_repack_without_room_is_skipped_like_the_gc(red): the same 56 packs withcode_mirror_gc_margin_gbabove the free space;gc_if_dueleaves all 56 and the gc mark untouched. Before the change it merges them.tests/unit/test_mirror_ready.py::test_a_clone_from_a_local_path_keeps_its_objects_in_a_pack(red):clone_and_pinfrom a local source whose objects are loose gives a mirror withcount: 0and one pack. Onmainit hascount: 3and no pack.test_code_compiler_checkout,test_mirrors,test_mirror_ready,test_doc_linksandtest_public_copy: 388 passed. The checkout transfer test also passed 5 times in a row alone.ruff check,ruff format --check,scripts/gates/mypy_gate.py,function_length_gate.py,check_no_secrets.py, and thedocs_reference,settings_example,settings_schema,settings_referenceandop_reach_censuschecks pass. The real-bubblewrap sandbox suite is left to CI.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code wrote the diff, the tests and the measurement. Checked: I reviewed the whole diff and its tests; the runs listed under Tests are the agent's, against
mainat the same commit.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.Note
Medium Risk
Changes mirror clone/fetch and periodic repack behavior on disk-heavy code-index hosts; mispacked mirrors or aggressive repacks could affect shared checkouts and sandbox bind limits, but scope is housekeeping and fetch packaging only.
Overview
Fixes shared compiler-tier checkouts when
LOOM_CODE_COMPILER_SHARE_MIRROR_PACKSis on: mirror clone and fetch paths now always persist objects as packs (not loose files), so checkouts that hard-link mirror packs see every fetched commit without re-downloading history.Mirror network git jobs set
fetch.unpackLimit=1; bare clones from local remotes add--no-localso loose source objects are packed.gc_if_duecan rungit repack --geometric=2when unkept pack count exceeds the newLOOM_CODE_MIRROR_GC_PACK_LIMIT(default 500), using the same disk headroom rules asgit gc, via refactored low-priority git housekeeping.Docs, example config, schema, and unit tests cover pack retention, repack limits, and skipped repack when disk is tight.
Reviewed by Cursor Bugbot for commit 2f18134. Bugbot is set up for automated code reviews on this repo. Configure here.