You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(install): fetch monorepo subdirectory deps as pin trees + exact cone blobs, in process - #5377
A monorepo subdirectory dependency (owner/repo/path#ref) on the git path paid for a partial bare clone of every branch's full history, plus clone, sparse-checkout, checkout and lazy-fetch git children, to land a cone of a few KB. For example, microsoft/apm costs 22.5 MB, 114k objects and about 2 s of git CPU.
After #4970 admission and the same transport gate the in-process pinned fetch uses (#5330/#5351), such a dependency is now two protocol-v2 requests:
The pinned commit with all its trees (deepen 1, filter blob:none), only when the server advertises fetch= filter and shallow.
Exactly the blobs git sparse-checkout --cone would write. The response must be exactly that set.
Every object id is computed in process. The written tree is the same as git's sparse cone. The landed .git has the in-process fetch's shape plus shallow, the trees, the cone's blobs and git's info/sparse-checkout file, and no promisor remote.
The dependency goes to git, writing nothing, when:
the cone holds a link, a gitlink, or an alias of .gitattributes;
an in-cone .gitattributes could change any written file's bytes. This is evaluated per written file by checkout_verify's attribute engine, also case-folded as core.ignorecase would match;
the gate refuses (same conditions as the in-process fetch; on Windows that includes the schannel backend);
any response or cap check fails.
The in-process sparse path is ON by default: no flag or config is needed to engage it. APM_NO_INPROCESS_SPARSE=1 is only a kill switch that forces git. It keys the install verdict record, so a recorded verdict is never reused across its values.
Merge order: #5383 lands first; this PR rebases onto it (both touch install/verdict_record.py).
Measured at 9ae2a68 against its merge-base with main, bb4744f (which already includes #5353 and #5376), on real github.com: the bench's real fixture, 10 public packages, 9 of them monorepo subdirectory or file dependencies. Cold, 6 interleaved pairs, paired CPU including children. Population: public github.com, anonymous.
OS / world
base CPU p50
new CPU p50
paired new/base
spawns
run
Linux
6.21 s
2.45 s
0.450
78 -> 12
45513153542
macOS
6.99 s
2.83 s
0.386
86 -> 12
45513174573
Windows (default Git for Windows, schannel)
12.19 s
7.00 s
0.542
104 -> 45
45519097336
The Windows row runs the bench's real world with Git for Windows' system TLS config carried into it, as a default install has it (schannel). Before that harness fix, the isolated world hid http.sslBackend=schannel, so git ran OpenSSL with no named CA and neither main nor this PR fetched in process there (run 45513122272). A probe of the real apm install on a default runner shows the in-process hits (run 45518723251).
The control tree-50 (no subdirectory deps), cold, 6 pairs, is neutral: Linux 1.010 (45513198595), Windows 0.995 (45513232286).
Human scope-approval comment: none yet for this item. It was ordered by the PERF lead chain under #4939 (lever S). W3d ruled the conditions: w3d:ruling:lever-s S1-S12, lever-s6prime T1-T7 and lever-s-t1prime U1-U7.
tests/unit/cache + test_inprocess_fetch_world + test_inprocess_fetch_windows_world: Linux 45447526059, Windows 45447565093, macOS 45447617664. All pass except test_git_env.py::test_clone_streams_git_progress_to_reporter, a known harness-order artifact that fails in isolation on main too and passes in the full PR run.
test_inprocess_sparse_live passed x3 on every OS: Linux 45450785605 and macOS 45450839815 at 916c3f1, Windows 45449888782 at b7abc73 (the only later change is the engaged count, which Windows does not assert). Single-file dependencies take the file download path, not a sparse checkout.
tests/integration/test_inprocess_sparse_cone.py:
cone and info/sparse-checkout byte-equal to git's for a directory, a file and a top-level cone;
a CRLF blob under * text=auto eol=lf is written as git writes it;
a pattern-aware *.bat eol=crlf with no .bat in the cone engages; a .bat or RUN.BAT in the cone refuses; a deeper override is evaluated by state;
an out-of-cone attributes file does not apply;
aliases of .gitattributes and a linked .gitattributes refuse;
a link in the cone refuses, and one outside the cone is ignored.
tests/integration/test_inprocess_sparse_attr_differential.py (W3d U6): 40 seeded trees x 2 core.ignorecase modes; every path's attribute state equals git check-attr -a.
tests/integration/test_inprocess_sparse_live.py (live): four real subdirectory dependencies on microsoft/apm and github/awesome-copilot, in process vs APM_NO_INPROCESS_SPARSE=1. Lockfile, deployed bytes and deploy-store receipts are identical, and every directory dependency engages on Linux and macOS.
Changelog
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
…cone blobs, in process
A sparse (subdirectory) dependency on the git path paid a partial bare clone of
every branch's full history (microsoft/apm: 22.5 MB, 114k objects, ~2 s of git
CPU) plus clone/sparse-checkout/checkout/lazy-fetch children, for a cone of a
few KB. After #4970 admission and B1's transport gate, it is now two
protocol-v2 requests: the pinned commit with all its trees (deepen 1, filter
blob:none), then exactly the blobs `git sparse-checkout --cone` writes. Every
object id is computed in process; a response that is not exactly the wanted
set, a link, gitlink or .gitattributes alias in the cone, or an in-cone
attribute that could change bytes (evaluated per written file by
checkout_verify's engine, case-folded as core.ignorecase) sends the dependency
to git. APM_NO_INPROCESS_SPARSE=1 forces git.
W3d rulings: lever-s (S1-S12), lever-s6prime (T1-T7), lever-s-t1prime (U1-U7).
Real github.com, cold, 6 pairs: Linux 4.74 -> 2.30 s CPU (0.477), spawns 77 -> 11.
apm-spec-waiver: transport-internal fetch shape; no OpenAPM requirement changes (same lockfile, bytes and receipts as git).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved findings allow writes outside staging, produce Git-incompatible attributes and file modes, leave capability responses unbounded, and place tests where taxonomy checks reject them.
Extends the existing in-process pinned fetch to GitHub monorepo subdirectory dependencies, supporting the install-performance work in #4939 without replacing the Git fallback.
Changes:
Fetches pinned commit trees and only the blobs needed for the sparse checkout.
Integrates sparse landings with cache verification and attribute checks.
Adds Git differential tests, a live install comparison, and a performance changelog entry.
File
Description
tests/unit/cache/test_inprocess_sparse.py
Tests cone parity, attributes, aliases, and link refusal.
…gated caps GET
W3d R1: every directory on the way to or inside a cone passes the same name
refusals as written files (nested .git and its aliases send the dep to git).
W3d R2: a directory that differs from the cone path only in case sends the
dep to git, as core.ignorecase cone matching would write it.
The capability GET goes through the first-answer gate and breaker, and its
per-repository memo is filled under a lock (one request per cold repository).
Attribute token names and alias folding no longer strip character sets.
The full and sparse in-process landings share one materialization-pin read.
apm-spec-waiver: transport-internal fetch shape; no OpenAPM requirement changes.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The sparse kill switch changes how install lands a dependency, so a
recorded verdict must not be reused across its values.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…th pack POSTs
The managed github-basic header is split from the env before the gate,
exactly as fetch_worktree does, and sent per request (exact origin, no
redirect hop, never on the session) on the capability GET and the trees
and blobs POSTs. Without managed auth nothing changes.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…5376)
#5376 made _requests_verify the one owner of verify= (OS store for
schannel). The caps GET now uses it, as _post does; a cell pins both to the
same value for an OS-store and a file trust.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Embedded carriage returns in .gitattributes can bypass the sparse safety gate, causing the fast path to write bytes that differ from Git and incorrectly mark the checkout as verified.
…fuse a lone CR; keep .gitattributes exec bit
- _caps_get streams the advertisement through _read_capped (shared with
_post): identity encoding only, 64 KiB cap, 30 s wall deadline, so an
oversized or trickling answer cannot exhaust memory or hold _caps_lock.
- An in-cone .gitattributes with a CR outside a CRLF line ending refuses:
git splits records only on LF, so '* diff\reol=crlf' sets eol=crlf.
- A 100755 .gitattributes keeps its mode, as git writes it.
- The A' cell drives _fetch_caps through the real _admitted_post (AQ004).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
POSIX named classes and BOM-prefixed .gitattributes can cause the sparse path to write LF bytes where Git requires CRLF and incorrectly mark those files as verified.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Reject BOM-prefixed .gitattributes files
src/apm_cli/cache/inprocess_fetch.py:1274
Git ignores a UTF-8 byte-order mark at the start of .gitattributes, but the shared parser retains it in the first pattern. A BOM followed by * eol=crlf therefore passes this gate and produces verified LF files where Git would write CRLF. Refuse BOM-prefixed sources until the canonical parser handles them, and add this case to the differential tests.
Reject POSIX character classes in attribute patterns
src/apm_cli/cache/inprocess_fetch.py:1282
A rule such as file[[:digit:]].md text eol=crlf passes this guard, but the shared attribute matcher does not support POSIX named classes and misses pkg/file1.md. The sparse path then writes LF bytes where Git would write CRLF and marks them verified. Conservatively refuse these patterns until the canonical matcher supports them, and add this case to the differential tests.
Avoid holding the global lock during capability requests
src/apm_cli/cache/inprocess_fetch.py:1201
The global _caps_lock is held throughout the capability GET and streamed body read, serializing capability requests across different repositories even after the first-answer gate has settled. This limits parallel downloads, and one stalled advertisement delays every other sparse dependency waiting for capabilities. Coordinate cache misses per upload URL, keeping the global lock limited to bookkeeping and preserving the existing first-answer and rate-limit gates.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because subtle attribute-parsing and case-matching differences from Git can cause sparse checkouts to silently write LF bytes where Git would write CRLF.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
full-integrationRun the full integration suite (ci-integration.yml) on this PR before merge
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A monorepo subdirectory dependency (
owner/repo/path#ref) on the git path paid for a partial bare clone of every branch's full history, plus clone, sparse-checkout, checkout and lazy-fetch git children, to land a cone of a few KB. For example,microsoft/apmcosts 22.5 MB, 114k objects and about 2 s of git CPU.After #4970 admission and the same transport gate the in-process pinned fetch uses (#5330/#5351), such a dependency is now two protocol-v2 requests:
deepen 1,filter blob:none), only when the server advertisesfetch=filter and shallow.git sparse-checkout --conewould write. The response must be exactly that set.Every object id is computed in process. The written tree is the same as git's sparse cone. The landed
.githas the in-process fetch's shape plusshallow, the trees, the cone's blobs and git'sinfo/sparse-checkoutfile, and no promisor remote.The dependency goes to git, writing nothing, when:
.gitattributes;.gitattributescould change any written file's bytes. This is evaluated per written file bycheckout_verify's attribute engine, also case-folded ascore.ignorecasewould match;schannelbackend);The in-process sparse path is ON by default: no flag or config is needed to engage it.
APM_NO_INPROCESS_SPARSE=1is only a kill switch that forces git. It keys the install verdict record, so a recorded verdict is never reused across its values.Merge order: #5383 lands first; this PR rebases onto it (both touch
install/verdict_record.py).Measured at 9ae2a68 against its merge-base with main, bb4744f (which already includes #5353 and #5376), on real github.com: the bench's
realfixture, 10 public packages, 9 of them monorepo subdirectory or file dependencies. Cold, 6 interleaved pairs, paired CPU including children. Population: public github.com, anonymous.schannel)The Windows row runs the bench's real world with Git for Windows' system TLS config carried into it, as a default install has it (
schannel). Before that harness fix, the isolated world hidhttp.sslBackend=schannel, so git ran OpenSSL with no named CA and neither main nor this PR fetched in process there (run 45513122272). A probe of the realapm installon a default runner shows the in-process hits (run 45518723251).The control
tree-50(no subdirectory deps), cold, 6 pairs, is neutral: Linux 1.010 (45513198595), Windows 0.995 (45513232286).Issue and approved scope
Issue: Refs #4939
Human scope-approval comment: none yet for this item. It was ordered by the PERF lead chain under #4939 (lever S). W3d ruled the conditions:
w3d:ruling:lever-sS1-S12,lever-s6primeT1-T7 andlever-s-t1primeU1-U7.This does not complete #4939.
Type of change
Testing
Hosted-runner cells, x3 per OS:
tests/unit/cache+test_inprocess_fetch_world+test_inprocess_fetch_windows_world: Linux 45447526059, Windows 45447565093, macOS 45447617664. All pass excepttest_git_env.py::test_clone_streams_git_progress_to_reporter, a known harness-order artifact that fails in isolation on main too and passes in the full PR run.test_inprocess_sparse_livepassed x3 on every OS: Linux 45450785605 and macOS 45450839815 at 916c3f1, Windows 45449888782 at b7abc73 (the only later change is the engaged count, which Windows does not assert). Single-file dependencies take the file download path, not a sparse checkout.tests/integration/test_inprocess_sparse_cone.py:info/sparse-checkoutbyte-equal to git's for a directory, a file and a top-level cone;* text=auto eol=lfis written as git writes it;eol=crlf,crlf,filter,ident,working-tree-encoding,[attr], quoted and unknown tokens refuse;*.bat eol=crlfwith no.batin the cone engages; a.batorRUN.BATin the cone refuses; a deeper override is evaluated by state;.gitattributesand a linked.gitattributesrefuse;tests/integration/test_inprocess_sparse_attr_differential.py(W3d U6): 40 seeded trees x 2core.ignorecasemodes; every path's attribute state equalsgit check-attr -a.tests/integration/test_inprocess_sparse_live.py(live): four real subdirectory dependencies onmicrosoft/apmandgithub/awesome-copilot, in process vsAPM_NO_INPROCESS_SPARSE=1. Lockfile, deployed bytes and deploy-store receipts are identical, and every directory dependency engages on Linux and macOS.Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1
req-XXXcovers,confirm the three-step ritual in the
development guide:
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.