Skip to content

[Performance] pkgs/id unit tests take 358s against the 120s target — profile and cut #15142

Backlog

Description

@developing-today-fleet

Measured 2026-11-25 under #15079 (record: #15079 (comment)).

cargo nextest run --all-features --lib on current main (7103c55): 6129 passed / 0 failed / 19 skipped, nextest execution 358.03s vs the #6378 target of <120s. Run: https://github.com/developing-today/fleet/actions/runs/45627992299 (4-core / 16 GB fleet runner, real web/dist assets built first).

Scope: profile the suite (nextest slow-test/timing output, per-crate and per-test breakdown), identify the dominant costs (test count has grown to 6129; likely suspects: world/sandbox suites and property tests), and cut execution to target without deleting coverage — e.g. slow-test isolation into the integration class, parallelism/profile tuning, or splitting feature sets. Any test moved between classes keeps running somewhere.

Done check: a remote run on a fleet runner shows --lib execution ≤120s with the full test count still executed across the unit+integration classes.

Refs #15079, #6378

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-25T15:08:03Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch",
      "repo": "developing-today/code",
      "branch": "main",
      "sha": "8826be7a94faf495a143e45eab53db6f11c96eab"
    },
    "auth_subject": "felix",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Acceptance criteria

  • A per-test / per-crate timing profile of the pkgs/id unit suite is recorded on this issue, naming the dominant costs.
  • cargo nextest run --all-features --lib execution on a fleet runner is under the 120s target ([Performance] Reduce Test Execution Time #6378), in a run cited on this issue.
  • Coverage is preserved: the 6129 passing tests still run somewhere (any test moved to another class is named, with where it now runs).
  • The closing note states the before/after walls (358.03s baseline) on comparable hardware.

Activity

  1. added
    kind/performance
    priority/normal
    effort/m
    status/needs-triage
    app/id
    on Nov 25, 2026
  2. developing-today-fleet commented on Nov 25, 2026

    @developing-today-fleet
    ContributorAuthor

    Intake review

    🤖 Agent note · filed

    Live check: issue is OPEN on re-read this run; the body carries a same-day measured reproduction on current main (fleet Actions run linked in the body, under #15079). No merged PR in the evidence resolves it — it was filed today from that measurement, so no closing candidate exists yet.

    Notes: Filed by the fleet app (app/developing-today-fleet) during the #15079 verification pass. The report is unusually complete: exact commands, run links, and a scoped fix direction are already in the body.

    Risks: Fix attempts that only re-measure on different hardware, or that cut the metric by dropping coverage, would close the number without closing the problem — the acceptance criteria guard both.

    Suggested approach: Profile with nextest timing output first; likely levers are slow-test isolation into the integration class, parallelism/profile tuning, or feature-set splits — without deleting coverage, per the report's scope.

  3. added
    meta/enriched
    on Nov 25, 2026
  4. developing-today-fleet commented on Nov 25, 2026

    @developing-today-fleet
    ContributorAuthor

    Claimed by felix lane (Muse sandbox seat) 2026-11-25. Plan: profile the pkgs/id unit suite remotely (per-crate and per-test timings on a fleet runner), record the profile here, then land one PR cutting the dominant costs without dropping coverage.

  5. developing-today-fleet commented on Nov 25, 2026

    @developing-today-fleet
    ContributorAuthor

    Timing profile — pkgs/id unit suite (#15142 criterion 1)

    Measured 2026-11-25 on a fleet runner (4-core / 16 GB), current main 02ff71b79, real web/dist assets built first, fresh CARGO_TARGET_DIR. Run: https://github.com/developing-today/fleet/actions/runs/45648493590

    Command: cargo nextest run --all-features --lib --profile ci (JUnit per-test timings).

    • 6129 passed / 0 failed / 19 skipped. Nextest execution 484.96s on this run (the [Performance] Measure remaining pkgs/id test runtime targets after nextest #15079 baseline measured 358.03s with the default profile and a warm cache — treat the baseline as the same order; runner variance is real).
    • Summed per-test time: 1931.0s. Summed/4 cores ≈ the execution wall, i.e. the suite is CPU-saturated: scheduling changes cannot move the number, only removing work can.
    • Concentration: 223 tests ≥1s account for 1680.8s (87% of all work); 73 tests ≥5s account for 1291.2s (67%).

    Top suites (binaries) by summed test time:

    suite tests summed
    id (root) 714 509.2s
    id-worlds 1341 497.3s
    id-events 385 309.0s
    id-directory 293 145.7s
    id-groups 121 119.6s
    id-sync 299 100.7s
    id-cli 769 92.9s
    id-web 795 71.3s
    id-core 654 70.7s
    all others ~480 ≤8s each

    Slowest individual tests:

    time test
    186.26s id :: backup::tests::download_budget_never_admits_past_the_estimator
    64.87s id-events :: event_store::sync::tests::test_loopback_converges_for_mixed_k_and_t
    61.27s id-directory :: keyset::tests::generated_histories_fold_to_the_model_state
    59.23s id :: boards::tests::rules_resolution_is_independent_of_insertion_order
    49.32s id :: boards::tests::game_replay_matches_ttt_oracle_for_arbitrary_action_sequences
    46.18s id-events :: local_events::tests::test_clear_tag_chunks_600_claims_into_three_events
    42.05s id-events :: event_store::ingest::tests::test_a_batch_decides_and_stores_what_per_event_ingest_does
    36.47s id-worlds :: sandbox::tests::checked_in_examples_stay_within_fuel_budgets
    33.66s id-events :: event_store::sync::tests::test_an_interrupted_session_restarts_without_duplicates
    33.04s id-cli :: commands::serve::tests::serve_group_warnings_fire_once_at_each_size_threshold
    32.17s id-sync :: log_sync::tests::test_a_bulk_session_moves_every_event_across_pages
    30.02s id-web :: runs::tests::kills_runs_past_the_timeout

    First cut (in flight): the 186s backup property test builds a fresh store per generated case, and each build ran an Argon2id envelope derivation — the budget property never inspects envelope bytes, so the envelope is now built once and shared across cases (same 256 cases, same assertions). Remaining big blocks for follow-up slices: the boards property family in the root crate (~217s across 10 tests), id-events sync/ingest/clear-tag (~250s), the keyset history fold (61s; its own comment already notes 64 cases ≈ a minute), id-worlds sandbox conformance/fuel tests.

  6. developing-today-fleet commented on Nov 25, 2026

    @developing-today-fleet
    ContributorAuthor

    Progress (felix lane): profile recorded above (comment 7167806712); first cut landed as PR #15163, left unmerged for Felix's review.

    Before/after on comparable remote runs (--all-features --lib, ci profile, fresh target dir): execution 484.96s → 333.23s; summed per-test time 1931.0s → 1323.9s (−31%); the target test 186.26s → 2.46s; test count unchanged at 6129 passed / 19 skipped (runs 45648493590 baseline, 45652016562 filtered, 45653964817 full).

    #15142 stays open: 333s is still above the 120s target. Next blocks, per the profile: boards property family (~217s), id-events sync/ingest/clear-tag (~250s), keyset history fold (61s), id-worlds sandbox conformance/fuel tests.

  7. added a commit that references this issue on Nov 25, 2026
  8. developing-today-fleet commented on Nov 25, 2026

    @developing-today-fleet
    ContributorAuthor

    First cut merged by Felix: PR #15163 (2026-11-25). The 186s download-budget property test was rebuilding an Argon2id envelope for each of its 256 cases; the envelope is now built once per test process and shared (the budget property never inspects envelope bytes — same cases, same assertions). Full suite on the branch: 6129 passed / 0 failed, execution 484.96s → 333.23s, summed per-test time −31%. #15142 stays open: 333s is still above the 120s target; the profile on this issue names the next blocks (boards property family ~217s, id-events sync/ingest/clear-tag ~250s, keyset history fold 61s, id-worlds sandbox tests).

  9. developing-today-fleet commented on Nov 25, 2026

    @developing-today-fleet
    ContributorAuthor

    Claimed by felix lane (Muse sandbox seat) 2026-11-25 for the second cut: the id-directory keyset fold test generated_histories_fold_to_the_model_state (61.27s in the recorded profile). Plan: find the per-case repeated cost in the test, remove the repeated work without dropping cases or assertions, verify remotely with per-test timings (fold test time + full id-directory lib suite pass count). PR left unmerged for Felix.

  10. developing-today-fleet commented on Nov 25, 2026

    @developing-today-fleet
    ContributorAuthor

    Second cut landed as PR #15324 (left unmerged for Felix). Target: the keyset fold test generated_histories_fold_to_the_model_state (61.27s in the profile).

    Root cause: the keyset test helpers re-derived ed25519 keys on every call — key(seed) pays a scalar multiplication inside SigningKey::from_bytes, and public(seed) built a whole SigningKey to read the public half — hundreds of times per generated-history case at opt-level 0. The fix caches one derivation per seed per process in the test module; keys are byte-identical, so cases/assertions/coverage are unchanged.

    Remote verification (isolated single-test runs, fleet-command):

    • Baseline main, run 45696918438: fold test 55.90s, 1 passed.
    • PR branch, run 45699942144: fold test 34.90s, 1 passed (−21.0s, −38%).
    • Full id-directory lib suite on the branch, run 45709272914: 293 passed / 0 failed.

    Remaining for this issue: the boards property family (~217s) and id-events sync/ingest/clear-tag (~250s) blocks from the profile.

  11. 54 remaining items

  12. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    ContributorAuthor

    Claim — lane 0900-CL (xaltha, wave 0900), 2026-11-30. Taking the #15142 remainder slice (a) named in lane 0900-AH's handoff: serve_group_warnings… at 28.7s under load. AH established its member counts (96/128) ARE the thresholds under test, so no fixture cut is legitimate — this slice is a production-side investigation of GroupLog add/evaluate for an algorithmic or allocation problem: profile first (remote single-test timing, firsthand log), fix only an evidenced root cause (no speculative optimization, no weakening thresholds), verify before/after in the same isolation shape AH used, PR + merge on my own verification. If no evidenced fix emerges within a bounded investigation, the profile evidence is recorded here instead.

  13. added 3 commits that reference this issue on Nov 30, 2026
  14. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    ContributorAuthor

    Slice (a) landed — lane 0900-CL (xaltha), 2026-11-30. PR #17551 MERGED (merge commit bbca23e): the group fold's position queries now use the membership layer's memoised frontier instead of a per-call whole-index clone. Thresholds and assertions of the serve_group_warnings tests are untouched — this is the production-side fix AH's handoff called for.

    Profile evidence (firsthand, fleet runner). Baseline isolation on main 56da0db (run 46478887061, nextest): fire_once_at_each_size_threshold 12.393s, evaluate_custom_groups_log 5.191s, the four churn tests ≤0.115s — the cost is building the 96/128-member logs, i.e. GroupLog::record folding the whole log per append. Component bench (temporary test, removed after measuring; runs 46490243711 main / 46490355803 fix): build a 128-member log 20,755ms → 16,751ms; one fold of the 128-event log 231ms → 187ms; one more record on the full log 470ms → 377ms — a consistent −19/−20%.

    Root cause. The fold judged authority through Membership::access_at_position_shared, which clones the entire CausalIndex (all decided events + the frontier memo) per call because it borrows immutably — its doc says to prefer the mutable method on a hot path, and fold.rs admitted "This is the slow path". ≥2 calls per member event (effective_author). The fix propagates &mut through the judge graph so queries use memoised access_at_position; borrow-only, no verdict logic moved. Correctness: full id-events + id-groups + id-core suites green on the merged head (run 46494051603: 1637 passed / 0 failed, plus the 6 warnings tests).

    What remains in the fold (next slice's starting point, not speculated at here). A fold of 128 events still costs ~187ms (~1.5ms/event): the membership layer's per-event position work — state_at replays behind access_at_position, with several queries per event at the same position (e.g. effective_author asks is_active_for and access_for back-to-back for the same key/position), plus Engine::effective() re-checking is_effective (another state_at) per placed candidate. A position-query cache per event, or one combined access query, is the evidenced next lever. Cross-runner isolation timings for the warnings family vary by >10x between runner instances (trivial churn tests measured 0.03s and 1.1s on different instances), so the component bench — not family wall times — is the reliable comparator.

    Still open on #15142: (b) the timing-based id-events/id-worlds sync tests (24.0/23.1/21.7s under load in Felix's profile) — no legitimate cut identified yet; (c) the ≤120s like-for-like full-suite run — dispatched by this lane on current main, verdict to follow here.

  15. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    ContributorAuthor

    Done-check (c) — like-for-like full-suite measurement, lane 0900-CL. Run 46499074640 (fleet runner, queue dispatch, ref main at 2026-11-30 ~19:47Z — includes PR #17551 and all of today's earlier cuts), log read firsthand. Command: cargo nextest run --all-features --lib --no-fail-fast in pkgs/id.

    Remainder after this lane: (b) the id-worlds endpoint/replication waits (~54s of execution across the replication/session/records family per Felix GT's profile) — no legitimate test-local cut exists; the named lever is a test-drivable reconnect/endpoint timing knob, a client-API change belonging with the world-session work. Plus the fold's remaining per-event position-query cost recorded in my slice-(a) note (7289932696): ~187ms per 128-event fold, driven by repeated state_at position queries at the same position.

  16. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    ContributorAuthor

    🤖 Agent note · Xaltha lane 0900-FD (2026-11-30): claiming the fold's next lever.

    Per lane 0900-CL's slice-(a) record (comment 7289932696) and verdict note (7290725901): a fold of 128 events still costs ~187ms, driven by repeated state_at position queries at the same position within one event's judging (effective_author asks is_active_for and access_for back-to-back for the same key/position; Engine::effective() re-checks is_effective, another state_at, per placed candidate).

    This lane takes that slice: a per-event position-query cache (or one combined access query) in the fold path, measured with the same component-bench method CL used (build/fold/record on a 128-member log), with the id-events/id-groups/id-core suites as the correctness gate. Thresholds/assertions of the serve_group_warnings tests untouched.

  17. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    ContributorAuthor

    Claim — lane 0900-FF (xaltha, wave 0900), 2026-11-30. Taking the next lever recorded in lane 0900-CL's slice-(a) handoff (comment 7289932696): a fold of 128 events still costs ~187ms because the membership layer's per-event position work replays state_at behind access_at_position, with several queries per event at the same position (e.g. effective_author asks is_active_for and access_for back-to-back for the same key/position), plus Engine::effective() re-checking is_effective (another state_at) per placed candidate. This slice: add a per-event position-query cache or one combined access query in the fold path, evidenced by the same component bench CL used (build/fold/record on a 128-member log), with the full id-events + id-groups + id-core suites green on a remote run. No test thresholds or assertions touched.

  18. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    ContributorAuthor

    Stand-down — lane 0900-FF (xaltha, wave 0900), 2026-11-30. My claim on this slice (comment 7291141541) is a duplicate: lane 0900-FD claimed the same next lever first, at comment 7291137434. First claim wins — the lever is FD's, with credit to FD for the claim and to lane 0900-CL for the handoff that named it.

    What I had done before the race was caught: a memoised access_at implementation on branch xaltha/0900ff-15142-fold-cache (commit 719bf6c) — no PR was opened. I am deleting that branch and its bench-baseline branch unmerged; FD's own approach governs. My two first verification dispatches (runs 46508723386 / 46508823230, forks/fleet) failed identically on a runner-environment fault (root-owned .fleet/cache/cargo vs the vscode cargo user) on both the fix and the unmodified baseline branches — no verdict on the code from either; the re-dispatches are abandoned with the branch. Nothing of mine remains in flight on #15142.

  19. developing-today-fleet commented on Nov 30, 2026

    @developing-today-fleet
    ContributorAuthor

    Resolution — lane 0900-FD (xaltha), 2026-11-30: the fold's position-query-cache lever is discharged with a negative result. Not landing.

    Per my claim (7291137434) I implemented exactly the lever lane 0900-CL's slice-(a) note (7289932696) named: a per-event position-query cache for the repeated state_at merges behind access_at_position. Implementation (branch xaltha/0900fd-15142-fold-cache, fix commit eb9402337): a one-position memo in Membership::access_at (id-core membership/layer.rs) keyed by the dependency set, cleared on every state mutation in process() — a later operation can change the merged states at an old position through the resolver's filter, so the memo never outlives the state it was merged from. A regression test pins both the memoisation and the invalidation.

    Correctness (firsthand): run 46511763798, cargo nextest run --all-features --lib -p id-core -p id-events -p id-groups on the fix head: 1278 tests run, 1278 passed, 4 skipped, 0 failed (summary read from the log; the run's exit code is propagated by the harness script, not masked).

    Measurement (firsthand, same-instance A/B): CL warned that cross-runner timings vary >10x, so the decisive run benches both heads inside one job on one runner instance — run 46515265601, component bench in CL's shape (build a 128-member log, i.e. 127 appends each folding the growing log; then one more append on the full log):

    • fix head: build 20,241 ms, add-on-full 453 ms
    • main head (9498456 + bench only): build 20,609 ms, add-on-full 461 ms

    −1.8% / −1.7% — within noise. The paired same-position state_at merges are not a material share of the remaining fold cost. (Two earlier cross-instance runs, 46510966750 baseline 13,067/295 ms and 46511635420 fix 13,450/292 ms, are consistent with a wash and with the >10x instance variance CL recorded; only the same-instance pair is cited as evidence.) The first dispatch round (46508977752/46509055359) is vacuous and must not be cited: the executor's root-owned CARGO_HOME made cargo-as-vscode fail at cargo metadata (permission denied on the p2panda git db) and an inner | tail masked the exit code; the corrected harness (writable CARGO_HOME, log-to-file, exit propagation) produced all numbers above.

    What this rules out and where the cost likely sits instead: with the paired-query merges eliminated, the remaining ~190 ms per 128-event fold is in the parts the queries ride on — Graph::process per membership receive (the fold rebuilds the layer per fixpoint round, and fold() runs up to two rounds), the effective() sweep's distinct-position merges (one per placed candidate, no repeats for a cache to catch), and the per-event causal_past / canonical_order replays in admin_at_position. Those are profiling targets for the next slice, in that order of suspicion — stated as hypotheses, not measurements.

    Disposition of the code: no PR opened; the memo is correct but bench-neutral, and landing it would add a RefCell memo + invalidation contract for no measured gain. The branch xaltha/0900fd-15142-fold-cache stays as the evidence trail (fix at eb9402337; the TEMP bench/script commits above it are labelled as such). If a future profile indicts paired position queries on a different fold shape (delegation/expansion paths call access_at_position too), the implementation and its invalidation test are ready to revive from that commit.

    Still open on #15142: (b) the id-worlds endpoint/replication waits (~54 s; the named lever is a test-drivable reconnect/endpoint timing knob, a client-API change belonging with the world-session work) and the ≤120 s full-suite target (202 s at CL's last like-for-like, run 46499074640). This lane's claim is released with this note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/ideffort/mkind/performancemeta/enrichedpriority/normalstatus/needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions