Skip to content

perf(ai): compile one call pattern per symbol in ast graph #4662

Description

@dan-petty

Problem or Motivation

devops ai ast graph runs re.search with a new pattern for each pair of body and name (src/devops_cli/ai/ast/graph.py:55-56, 71-72). That is 376,800 calls for 1,849 names, and each call misses the re cache. It also runs one rglob for each of 32 extensions (graph.py:20-22).

The dry-run test runs the command on the whole repository and checks only exit 0. It takes 15.06 s in CI and 19.3 s locally with no coverage (measured).

Saving: 15 s of CI worker time per run (measured) and 19 s locally.

Found by the CI and test audit of 2026-11-11. The account runs at most 20 hosted jobs at one time (measured), so each job that does no work makes the queue of each pull request longer.

Proposed Solution & Architectural Design

  • Compile one pattern per name (functools.lru_cache), or tokenise each body once with \b(\w+)\s*\( and intersect the tokens with the set of names.
  • Walk the tree once with os.walk, and prune the ignored folders.
  • Run the dry-run test with --dir on a small tmp tree.

Risk: Low. The call regex stays the same.

Target Subsystem

AI & Agentic Review Pipeline (src/devops_cli/ai/ast/graph.py, tests/commands/test_ai_local_dry_run.py).

Existing Tool Considered

The standard library: re, functools.lru_cache and os.walk. No new tool. Cost: about 15,000 tokens and 1 hour.

Acceptance Criteria

  • The build over the repository gives the same 1,849 nodes and 6 edges in 5 s or less (from 17.9-19.8 s; with cached patterns it took 4.5-4.8 s, measured).
  • The dry-run case takes 1 s or less.

Dependencies

None.

Activity

  1. added
    source/agent
    type/infra
    scope/ai
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/infra. The perf prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. Saves 15 s of CI worker time per run but does not fix a defect or block a release.
    • Value: Medium. Reduces CI queue time for all pull requests on a 20-job account.
    • Effort: Low. Standard library only, one file plus one test, estimated at 1 hour.
    • Related: perf(ai): high-performance AST context packer with binary search truncation #118, which asks for a different change. Both are perf(ai) items in the AI subsystem, but 118 optimises context_packer truncation while this optimises ast/graph.py regex and file-walk.
  3. added
    priority/p2-medium
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 11, 2026
  4. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  5. added a commit that references this issue on Nov 12, 2026
  6. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 12:40 UTC

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

    effort/lowpriority/p2-mediumscope/aisource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions