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
test(perf): authenticated install journeys and deterministic counters in the bench - #5340
The perf bench measured only the anonymous public github.com path. Most real installs run authenticated: private repositories, GHE, Azure DevOps, GitLab, or a token to avoid the anonymous rate limit. Those installs take the token-first git CLI path, which none of the anonymous-path levers reach.
This test-only change adds that population to the bench, permanently, plus hardening of the perf promise engine's counters:
install-cold-auth and install-warm-auth journeys (tests/benchmarks/journeys.py). Same fixtures as install-cold / install-warm, plus a fixed placeholder token (GITHUB_APM_PAT) and APM_GITHUB_AUTH_FIRST=1. The offline mirror accepts any github.com token, so the child takes the real token-first path with no secret involved. A journey's extra environment applies only to that journey and is restored afterwards.
the counter hook runs the next sitecustomize on sys.path, so the lifecycle network guard stays installed;
counted os.stat / os.lstat / realpath keep their os.supports_* memberships, so platform capability checks answer the same;
hashlib.new (and so hashlib.file_digest) counts as a hash object.
Re-measured count budgets (tests/perf/count_budgets.json): counting hashlib.new makes checkout verification visible, so four rows move, measured by the required check itself (CI run 45398516932). install-cold hash_objects 1531 -> 1857, hashed_bytes 2716513 -> 3220036; install-warm hash_objects 1456 -> 1825, hashed_bytes 2814521 -> 3325920. The code is unchanged; the counter now sees more of it. Every other row is unchanged.
Main fix: count budgets after perf(install): in-process pinned fetch #5330 (the required check has been red on main since perf(install): in-process pinned fetch #5330, the in-process pinned fetch, landed). A cold install now fetches in process, so it spawns no git clone. The cell now asserts HTTP fetch work instead of a clone spawn, and install-cold files_written 1367 -> 1520 and git.var 2 -> 4 are re-measured (CI run 45401098857): that work now runs in the counted apm process.
On the real fixture the authenticated journeys use the caller's GITHUB_APM_PAT and fail without one, instead of measuring a rejected placeholder token.
Windows git command lines with a quoted executable path ("C:\Program Files\Git\...") now parse to the right verb.
First reading, authenticated vs anonymous, on main 40b9a7b5, tree-50, rtt 30, CPU p50:
population
Linux cold
Linux warm
Windows cold
Windows warm
public github.com anonymous
18.70 s
13.68 s
32.77 s
15.72 s
authenticated token-first
20.45 s
15.62 s
35.38 s
19.63 s
The authenticated overhead is 50 extra git ls-remote (one per package) and about 91 extra git config probes (Linux counts). Runs: 45374206022 (Linux), 45374352797 (Windows).
Human scope-approval comment: bench and harness work under the approved #4939 perf scope (standing PERF approval for groundbreaking performance work); test-only.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The counter setup shadows the existing startup hook, disabling Python socket and DNS restrictions during counted commands and creating a critical network-isolation regression.
This test-only PR expands the performance benchmark for #4939 to cover authenticated installs and adds deterministic counters to measure work without relying solely on timing.
Changes:
Adds cold and warm authenticated install journeys with journey-scoped environment overrides.
Adds reusable counters for git commands and optional filesystem and hashing activity.
Improves parsing of quoted Windows git executable paths.
File
Description
tests/fixtures/perf/counters.py
Adds helpers to enable counters, run commands, and aggregate logs.
…new, real-fixture auth uses the caller token
The counter sitecustomize now runs the next sitecustomize on sys.path, so the
lifecycle network guard stays installed. hashlib.new (and file_digest) count
as hash objects. On the real fixture the authenticated journeys use the
caller's GITHUB_APM_PAT and fail without one, instead of a placeholder token.
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
The instrumentation alters Linux filesystem capability detection and miscounts hash objects, SHA-384 work, and its own log writes, compromising measured behavior and benchmark accuracy.
The filesystem hook counts its own log write: _flush() stores the live _fs dictionary in the record, then opens _LOG before serializing it. Every record with filesystem activity therefore gains an extra files_written event from instrumentation rather than the measured command. Exclude the counter log from the open-event hook.
copy() creates another underlying hash object without incrementing hash_objects, so workloads using copies are undercounted. This includes HMAC finalization with the wrapped SHA256 constructor, used for verdict-record digests in src/apm_cli/install/verdict_record.py:415. Increment the object counter here without counting copied input bytes again.
SHA-384 work is still invisible to the counters: compute_policy_hash() in src/apm_cli/policy/project_config.py:237 uses hashlib.sha384() for supported SHA-384 policy pins, but this constructor is not wrapped. Those integrity checks therefore contribute neither hash_objects nor hashed_bytes, unlike equivalent SHA-256/SHA-512 checks. Include sha384 in the wrapped constructors so changing a supported policy hash algorithm cannot look like eliminated hashing work.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The counters inflate filesystem activity with their own log writes, omit SHA-384 hashing, and retain inherited filesystem counting despite an explicit opt-out, undermining benchmark accuracy.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Exclude the counter log from filesystem write totals
Opening _LOG in _flush() increments files_written before the shared _fs dictionary is serialized, so each process includes the counter's own output as application filesystem work. Exclude the counter log from this hook to avoid inflating the count as the number of processes grows.
The constructor list omits hashlib.sha384, which compute_policy_hash() uses for supported SHA-384 policy pins (src/apm_cli/policy/project_config.py:236-237). Those integrity checks contribute neither objects nor bytes to these counters, while equivalent SHA-256/SHA-512 checks and hashlib.new("sha384", ...) are counted. Please wrap SHA-384 too so the counters do not silently omit this supported hashing path.
Remove inherited filesystem counting when fs is disabled
tests/fixtures/perf/counters.py:41
If the supplied environment already contains APM_PERF_COUNT_FS=1, fs=False leaves filesystem counting enabled, including when reusing an environment returned by counted_env(..., fs=True). The expensive wrappers can therefore contaminate timing comparisons despite the explicit opt-out. Remove the inherited flag when fs is false.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The hardened hook adds checkout-verification hashing beyond the existing count-budget headroom, so stale budgets falsely report performance regressions and must be remeasured, updated, and validated.
…ounted
install-cold hash_objects 1531 -> 1857, hashed_bytes 2716513 -> 3220036;
install-warm hash_objects 1456 -> 1825, hashed_bytes 2814521 -> 3325920.
Same code, more of it counted: checkout verification hashes through
hashlib.new. CI run 45398516932 at cc38133.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Main is red on the required count-budget check since #5330: a cold install
now fetches in process, so it spawns no git clone, and its object writes and
one git var run in the counted apm process. The cell asserts HTTP fetch work
instead of a clone spawn; install-cold files_written 1367 -> 1520 and
git.var 2 -> 4 are re-measured (CI run 45401098857).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The cold cell asserts no git clone and HTTP requests, so if the in-process
fetch stops engaging the clones turn the check red. The five install-cold
spawn rows #5330 removed (clone, init, checkout, cat-file, ls-tree) are
dropped, so any of them reappearing reads as unbudgeted. files_written takes
the max of CI runs 45401098857 (1520) and 45403013362 (1732).
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
The Windows command-line parser mishandles backslash-escaped quotes, causing Git fetch commands to be recorded under a nonexistent verb and losing the actual fetch count.
…urneys
Measured in CI run 45409372587 at baa516b (main 784c9da + #5340). The
cold, warm and no-op rows stay as #5340 cut them; the full re-cut follows
the perf queue.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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
The perf bench measured only the anonymous public github.com path. Most real installs run authenticated: private repositories, GHE, Azure DevOps, GitLab, or a token to avoid the anonymous rate limit. Those installs take the token-first git CLI path, which none of the anonymous-path levers reach.
This test-only change adds that population to the bench, permanently, plus hardening of the perf promise engine's counters:
install-cold-authandinstall-warm-authjourneys (tests/benchmarks/journeys.py). Same fixtures asinstall-cold/install-warm, plus a fixed placeholder token (GITHUB_APM_PAT) andAPM_GITHUB_AUTH_FIRST=1. The offline mirror accepts any github.com token, so the child takes the real token-first path with no secret involved. A journey's extra environment applies only to that journey and is restored afterwards.tests/benchmarks/spawn_counter/sitecustomize.py; the counters fixture itself landed on main with test(perf): required count budgets for install cold, warm and no-op (perf promise engine layer 1) #5338):sitecustomizeonsys.path, so the lifecycle network guard stays installed;os.stat/os.lstat/realpathkeep theiros.supports_*memberships, so platform capability checks answer the same;hashlib.new(and sohashlib.file_digest) counts as a hash object.tests/perf/count_budgets.json): countinghashlib.newmakes checkout verification visible, so four rows move, measured by the required check itself (CI run 45398516932). install-cold hash_objects 1531 -> 1857, hashed_bytes 2716513 -> 3220036; install-warm hash_objects 1456 -> 1825, hashed_bytes 2814521 -> 3325920. The code is unchanged; the counter now sees more of it. Every other row is unchanged.git clone. The cell now asserts HTTP fetch work instead of a clone spawn, and install-cold files_written 1367 -> 1520 and git.var 2 -> 4 are re-measured (CI run 45401098857): that work now runs in the counted apm process.realfixture the authenticated journeys use the caller'sGITHUB_APM_PATand fail without one, instead of measuring a rejected placeholder token."C:\Program Files\Git\...") now parse to the right verb.First reading, authenticated vs anonymous, on main
40b9a7b5, tree-50, rtt 30, CPU p50:The authenticated overhead is 50 extra
git ls-remote(one per package) and about 91 extragit configprobes (Linux counts). Runs: 45374206022 (Linux), 45374352797 (Windows).Issue and approved scope
Issue: Refs #4939
Human scope-approval comment: bench and harness work under the approved #4939 perf scope (standing PERF approval for groundbreaking performance work); test-only.
This adds measurement only; #4939 continues.
Type of change
Testing
The CI bench runs above exercised both journeys and the counters on Linux and Windows.
Changelog
changelog.d/<pr>.<section>.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated