Skip to content

perf(task): prune validation and implicit scheduler graphs - #79

Merged
earakely-scale merged 4 commits into
scaleapi:mainfrom
morluto:codex/perf-task-graphs
Oct 7, 2026
Merged

earakely-scale merged 4 commits into
scaleapi:mainfrom
morluto:codex/perf-task-graphs

Conversation

@morluto

@morluto morluto commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #76.

Prune unused task validation work and replace dense graphs with predecessor chains for wholly implicit sequential tasks. Mixed/explicit graphs retain their existing behavior. Both initial scheduling and retry rearming use the reduced representation.

Workload Before After Speedup
Validate 3,000 implicit steps 100.629 ms 0.242 ms 416×
Validate 500 self-retrying steps 734.573 ms 0.051 ms ~14,500×
Build 3,000-step scheduler graph 224.843 ms 0.872 ms 258×

The graph uses 2,999 edges instead of 4,498,500. Peak traced allocations: 39.1 MB → 1.32 MB. Measurements are validation/graph microbenchmarks on macOS arm64, Python 3.12.13, against 602d730, with five timing samples. They do not measure complete task execution; earlier-target retries and mixed graphs retain their existing validation costs.

Reproduce:

PYTHONPATH=src:packages/agentenv-protocol/src .venv/bin/python tst/benchmarks/task_graphs.py --base 602d730 --steps 1000 3000 --retry-steps 500 --repeats 5

Validation:

  • The baseline now loads its own methods, dependency helpers and state schema; regression coverage prevents mixed revisions and constructor mismatches.

  • 157 focused task/retry tests passed, including actual execution, persisted retries, resume/end boundaries, callbacks and cancellation.

  • Full unit and protocol suites: 6,238 passed, 13 skipped.

  • Deterministic regressions check graph edge counts and absence of unused prefix slicing/self-retry ancestry.

  • Independent review completed with no actionable findings; plugin API check and diff checks passed.

Separate commits keep validation pruning and scheduler graph reduction reviewable. This PR is independent of the journal, Explorer and existing context-diff PRs.

RetriggerConfidence Score: 5/5

The PR appears safe to merge; both earlier benchmark findings are addressed, and no new issue was established.

Summary

Task validation and scheduling now skip unnecessary work for tasks that use the default sequential order. The PR also adds a benchmark that compares these costs with methods loaded from a chosen Git revision.

  • Implicit tasks skip unused checks while they are being validated.
  • Wholly implicit tasks keep their order with a predecessor chain.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Build scheduler state] --> B{All active steps implicit?}
    B -->|Yes| C[Link each step to its predecessor]
    B -->|No| D[Keep the existing dependency edges]
    C --> E[Use dependency map for retry rearming]
    D --> E
Loading

Reviews (3) · Last reviewed commit: "fix(benchmark): load task baselines from..." · Reviewed by Greptile

@morluto
morluto marked this pull request as ready for review October 6, 2026 19:54
@morluto
morluto requested a review from a team as a code owner October 6, 2026 19:54
Comment thread tst/benchmarks/task_graphs.py Outdated
_drive_dag rebuilt each active step's dependency ids to re-arm after a
retry's rollback, mirroring _build_scheduler_state's chain-or-dense
choice. _build_scheduler_state now records them on _SchedulerState as
`dependencies`, and _rearm reads that, so the choice lives in one place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/agent_env/task/task.py
@earakely-scale

Copy link
Copy Markdown
Collaborator

Nice PR, approved

@earakely-scale
earakely-scale merged commit 9085a60 into scaleapi:main Oct 7, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce task validation work and implicit scheduler graph size

2 participants