Skip to content

chore(roadmap): cut the 4 to 5 minute intake call #4404

Open
4 of 4 issues completed
Open

Description

@dan-petty

Problem

devops roadmap intake takes 4 to 5 minutes for one issue. In one session, 14 calls took between 4 min 19 s and 6 min 58 s each. The rule "one devops ai call at a time" makes batches slow: filing five issues takes about 25 minutes. The cause is not known.

What to find out

  1. Where the time goes: the embedding call for the duplicate check, the nearest-neighbour search over the open and closed issues, the triage model call (local qwen3.8:27b in the CLI environment, deepseek-v4.1-flash-1017 in the Service), GitHub requests (pacing by devops gh), label and project writes, the reason comment.
  2. Whether the local model is slow because other agents use the same GPU, or the call is slow by itself.
  3. What can be cut with no loss: a cache of the issue embeddings, a smaller shortlist, parallel reads, one batch of GitHub writes.

Done when

A timing table by phase for five runs, and a fix issue for each large phase. A target of 1 minute for one issue is set in the fix issues.

Related: #4372 (a different fault), the triage task slot.

Proposed design

Problem statement

devops roadmap intake takes 4 to 5 minutes for one issue. A person measured five runs on 2026-11-11 and filed four fix issues. No command in the repository measures the phases again, so nobody can show that the fix issues reach the 1 minute target. This change records the duration of each intake phase, sends each duration to the step histogram, and prints a table of several runs with their medians.

Acceptance criteria

Requirement: Phase durations of one intake run

One intake run SHALL record a duration for each of the six phases: read, parse, embed, neighbour, model and write.

Scenario: Six phase entries

  • WHEN A test runs one intake over the Roadmap builder with a model and a store that shift the fake clock by a known duration in each phase.
  • THEN The timing record holds one entry for each of the six phase names, and each entry equals the sum of the shifts of that phase.

Requirement: Phase samples in the step histogram

Each timed phase of an intake run SHALL send one sample to devops_cli_roadmap_step_seconds with the row intake and the phase's step name.

Scenario: Six step samples

  • WHEN A test runs one intake with the telemetry emitter replaced by a capture.
  • THEN The capture holds at least one sample for each of the six step names under the row intake.

Requirement: Append of timed runs to one file

The intake command SHALL append one JSON line for each timed run to the file that --timing-json <path> names.

Scenario: Five runs append five lines

  • WHEN A test runs the intake command five times with --timing-json pointed at one temporary file.
  • THEN The file holds five lines, and each line parses as JSON with a phases object of six entries and total, model, host and started_at values.

Requirement: Markdown table of the runs

devops roadmap intake-timing <path> SHALL print a Markdown table with one column for each of the six phases, a total column, an other column and one row for each recorded run.

Scenario: Five runs print five rows

  • WHEN A test renders a file of five runs with known durations.
  • THEN The output has a header row that names the six phases, the total and the other column, and five body rows.

Requirement: Medians of the phases and the run

The report MUST print the median of each phase, of the other time and of the whole run.

Scenario: Median of five known values

  • WHEN A test renders five runs whose read durations are 1, 2, 3, 4 and 5 seconds.
  • THEN The read median reads 3 s, and the total median equals the median of the five run totals.

Requirement: No record without the option

The intake command SHALL write no timing record when --timing-json is absent.

Scenario: No option, no record

  • WHEN A test runs one intake without --timing-json in a temporary directory.
  • THEN No timing file exists in the directory, and the run prints no timing line.

Requirement: The intake writes stay the same

The change MUST leave the label writes, the field writes and the reason comment of an intake run unchanged.

Scenario: Timing on and timing off write the same

  • WHEN A test runs one intake twice with the same stubs, once with --timing-json and once without it.
  • THEN Both runs record the same list of issue writes and the same reason comment text.

Requirement: A page for the report command

The report command SHALL have the page docs/roadmap/intake-timing.md, and its help SHALL name that page.

Scenario: The help names the page

  • WHEN A test reads the help text of devops roadmap intake-timing.
  • THEN The help text holds docs/roadmap/intake-timing.md, and that file exists.

Existing Tool Considered

No alternatives check has run for this issue. OpenTelemetry is already the project's telemetry library: observe_step sends the seconds of each job step to the histogram devops_cli_roadmap_step_seconds (src/devops_cli/roadmap/step_metrics.py, src/devops_cli/telemetry/instruments.py, docs/TELEMETRY.md). It covers the seconds of each phase of every run, the Service's runs included, and Prometheus computes their medians. It lacks a per-run record that a test reads back as one row, and a Markdown table across runs. The change adds a small recorder and renderer on top of observe_step; it builds no timer and adds no dependency. Cost: about 10,000 tokens to build, about 2,000 tokens a year to keep and fix, and about 3 hours of elapsed time.

Key questions

  • Which helper records the duration of each intake phase?: The existing observe_step helper on the devops_cli.core.clock.monotonic seam, with six new intake step names. Each phase also sends its seconds to devops_cli_roadmap_step_seconds. The clock fixture moves the seam, so a test sets each duration with no sleep. (best practice) [sources: src/devops_cli/roadmap/step_metrics.py, src/devops_cli/core/clock.py, tests/support/fakes/clock.py, src/devops_cli/telemetry/instruments.py]
    • Chosen: The existing observe_step and the step histogram. It is the project's timing helper for a job step. It sends the phase samples to the existing histogram, and the clock fixture moves its reading, so a test needs no sleep.
    • Rejected: A new timer on time.perf_counter. It duplicates observe_step. The clock fixture does not move time.perf_counter, so a test would need real sleeps, which docs/TESTING.md forbids.
    • Rejected: OpenTelemetry spans. A span needs a collector to read. It gives no per-run row that a test renders offline.
    • Rejected: py-spy sampling of the live process. It gives a flamegraph of a live process, not a per-run record. The offline test suite cannot run it.
  • Which phases get a timer?: The six phases that the measured runs name: read, parse, embed, neighbour, model and write. The parse is its own phase, because the largest fix issue targets it. The report also prints the run total and the other time, so the time outside the six is visible. (best practice) [sources: src/devops_cli/roadmap/intake/intake.py, src/devops_cli/roadmap/stores/store.py, docs/roadmap/intake.md]
    • Chosen: Six phases, the parse apart from the read. The parse takes about 89 s of the 163 s read in the measured runs, and one fix issue targets it. A separate timer shows a change to it.
    • Rejected: The body's six phases, the parse inside the read. The parse then hides inside the read, so a change to the parse shows as a change of the read.
    • Rejected: One timer for the whole run. It gives one number and no breakdown, so it cannot show where the time goes.
    • Rejected: Timers in the GitHub client only. It misses the embedding call, the nearest-neighbour search and the model call.
  • What command interface gives the report its runs?: devops roadmap intake --timing-json <path> appends one JSON line per run. devops roadmap intake-timing <path> prints the table from that file. (best practice) [sources: src/devops_cli/commands/roadmap.py, src/devops_cli/lang/en/help.py, docs/roadmap/intake.md]
    • Chosen: One option that appends, and one command that renders. It keeps the table of several runs, and a test renders a fixed file with no live call. The report command makes no external request, so it declares the no-external-request dry-run class.
    • Rejected: One option that prints a single row. It cannot show the several runs that the fix issues need.
    • Rejected: An environment variable. It hides the record path from the command help and from the test.
    • Rejected: The report proposes a fix issue title for each large phase. A person filed the four fix issues from the measured table, so the report adds none. A 23 s model call would get a title that the measurement does not justify.
  • Does the timing record cover the Service's runs?: The JSONL record is a CLI option. The histogram covers the Service's runs too, because the same step names come from plan_intake. (best practice) [sources: src/devops_cli/roadmap/step_metrics.py, src/devops_cli/telemetry/instruments.py, docs/TELEMETRY.md, src/devops_cli/roadmap/intake/intake.py]
    • Chosen: The histogram for both, the file for the CLI. The histogram already holds the step seconds of every run. A file for each Service round would grow without limit beside schedule.json.
    • Rejected: A timing file for each Service round. It grows without limit, and no test reads it.
  • Which test doubles does the timing test use?: The intake tests use the Roadmap builder, FakeModel and the clock fixture. The fixture moves devops_cli.core.clock.monotonic, so a test sets each phase duration with no sleep. [sources: tests/support/roadmap_intake.py, tests/support/fakes/clock.py, tests/roadmap/intake/test_roadmap_intake_command.py, docs/TESTING.md]
  • Does this change make one of the cuts?: No. The change measures only. The four fix issues hold the cuts. (best practice) [sources: src/devops_cli/ai/rag/embeddings.py, docs/TELEMETRY.md, src/devops_cli/roadmap/intake/intake.py]
    • Chosen: Measure only. The four fix issues hold the cuts. A cut in this change would hide the baseline that the next measurement compares with.
    • Rejected: Add the issue-embedding cache. The cache exists, and devops_cli_embedding_cache_lookups_total counts its lookups. The measured runs show that the cache misses.
    • Rejected: Read the issues in parallel. It changes the run before the report shows the read time after the fix issues.
    • Rejected: Send one batch of GitHub writes. It changes the run before the report shows the write time after the fix issues.
  • Where does one intake run start?: The CLI path starts at intake_cmd in src/devops_cli/commands/roadmap.py, which calls plan_intake in src/devops_cli/roadmap/intake/intake.py. The Service runs the same plan. [sources: src/devops_cli/commands/roadmap.py, src/devops_cli/roadmap/intake/intake.py, src/devops_cli/roadmap/run.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-11: not-applicable.
Class: chore, no search.
Tool: none found.

Sub-issues

Sub-issues

4 of 4 Issues completed
Loading 4 sub-issues

Activity

  1. added
    source/agent
    type/chore
    scope/roadmap
    status/new
    value/medium
    effort/medium
    on Nov 10, 2026
  2. dan-petty commented on Nov 10, 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/chore. The chore prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It slows developer workflow but does not block delivery or affect end users.
    • Value: Medium. It cuts 4 to 5 minutes per issue from the intake path, saving time for the team.
    • Effort: Medium. It requires timing five phases over five runs and filing fix issues for each slow phase.
    • Related: feat(review): review performance baseline per-stage timing, calls and tokens on a fixed corpus #473, which asks for a different change. Both items add per-stage timing to a devops command, but #473 targets review while the candidate targets roadmap intake.
  3. added
    priority/p2-medium
    on Nov 10, 2026
  4. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at cbd3c64 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • Who records the five-run timing table? (a person decides)
  5. added
    owner/agent
    on Nov 10, 2026
  6. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Timing table of the intake call

    I timed five runs of devops roadmap intake --title <t> --body-file <f> for one new candidate on 2026-11-11. Runs 1 to 3 used --plan: they read GitHub and call the model, but they write nothing. Runs 4 and 5 used --confirm, and they filed #4445 and #4447. A scratch harness put a monotonic timer around each phase function in the same process. Run 1 also ran under cProfile, so its CPU-bound phases are longer. The host is the shared devcontainer, with a load average of 67 to 85 during the runs.

    All values are seconds. The median is of runs 2 to 5.

    Phase Run 1 (cProfile) Run 2 Run 3 Run 4 Run 5 Median
    GitHub issue listing, total 198.1 178.8 147.4 163.9 162.4 163.2
    · page transfer (45 pages, state=all) n/a 80.2 74.6 71.5 56.3 73.0
    · of which rate-limit pacing n/a 31.0 27.7 17.1 7.3 22.4
    · body parse, split_record (4,431 bodies) 140.0 92.1 67.6 85.3 100.1 88.7
    Embeddings, total 136.7 142.6 154.7 159.5 159.1 156.9
    · remote call (1,800 texts, 57 batches) 132.5 135.4 151.7 152.2 153.4 152.0
    · cache hits 0 0 0 0 0 0
    Nearest-neighbour search 10.7 2.6 0.9 1.3 2.6 1.9
    Triage model call 28.5 21.5 15.5 25.2 27.7 23.4
    Read of .github/labels.yml 1.0 1.8 2.2 1.3 1.4 1.6
    Write phase (13 calls) none none none 28.7 28.2 28.5
    Whole command (wall) 382 351 324 385 386 368

    What the table shows

    1. GitHub listing, about 45 %. Each run reads all 45 pages of the issue listing again, because the session keeps its ETags only in memory (refactor(github): the github session owns transport, ledger, error classes and link pagination #983) and a CLI run is a new process. The pacing of the shared quota takes 7 s to 31 s of it. Then split_record parses all 4,431 bodies with markdown-it, but only 1,084 bodies hold a record block. On an idle copy of the bodies, the parse takes 18 s to 23 s of CPU time, so the load of the host makes it 3 to 5 times longer.
    2. Embeddings, about 45 %. Each run sends all 1,800 texts of the comparison set to qwen3-embedding:0.6b through the AI gateway again, with 0 cache hits. The Valkey tier is off on a workstation (valkey.url is localhost, and the connection is refused), and the memory tier holds 1,024 entries, which is less than one comparison set.
    3. Triage model, 4 % to 8 %. The call goes to qwen3.8:27b through the AI gateway, with a request of 4.7 to 6.2 thousand characters and a shortlist of 5. It is not a large phase. I did not measure if other agents on the same GPU make it slower.
    4. Nearest-neighbour search, less than 3 s. It is not a large phase.
    5. Writes, about 28 s. A new candidate gets 13 GitHub calls one after the other: the issue, the sub-issue link, 2 labels, a read and a PATCH for each of 4 fields, and the reason comment.

    Fix issues, each with the target of 1 minute for the whole call

    Phase Issue Target of the item
    Body parse #4445, pull request #4455 3.6 times less CPU time for the parse, with the same result
    Embeddings #4447 5 s or less when 50 or fewer texts changed
    GitHub listing #4448 10 s or less when 20 or fewer issues changed
    Writes #4452 5 calls and 10 s or less

    With all four, the estimate for one call is about 1 minute: 10 s listing, 5 s embeddings, 23 s model, 2 s search, 10 s writes, and the parse of the changed bodies only.

    This comment holds the timing table that the refine question asks for, and the four sub-issues of this item track the fixes.

  7. added
    status/ready
    and removed
    status/new
    on Nov 11, 2026
  8. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 2f6114f (see proposed design in issue body).

    Moved to new items: #4499.

  9. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: chore. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-11. A person decides what this means for the item. The check changes no label and closes no issue.

  10. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    Embedding phase after #4447 (pull request #4546), measured on the devcontainer on 2026-11-11 with devops roadmap intake --plan:

    • Before: 155.1 s in embed_texts, 59 gateway requests, 1,866 texts to the model, 0 cache hits. Whole call 249 s.
    • After, second run: 11.3 s in embed_texts, 1 gateway request, 1 text to the model, 1,867 disk hits. Whole call 89 s.

    The disk lookup of 1,867 texts takes 0.55 s. The rest is one gateway request: three single-text embedding requests took 13.4 s, 9.4 s and 10.2 s. Thus the target of 5 s for 50 changed texts in #4447 needs a faster single embedding request at the gateway. The before batches show the same latency: 59 requests, 4 at a time, in 155 s is about 10 s for each request.

  11. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Measurements from 13 devops roadmap intake --title ... --confirm runs on 2026-11-12 (01:00 to 04:10 UTC), filed one at a time behind the intake lock while other sessions also filed:

    • Time inside the command (lock wait not included): median 4 min 11 s, range 2 min 30 s to 6 min 34 s.
    • 1 run failed before it wrote anything: Could not read .github/labels.yml at the default branch in dan-petty/devops-cli (exit 124): GitHub API command timed out after 30.0 seconds (after 2 min 24 s). A retry passed.
    • In the same hour, devops gh api failed once with gh auth token could not run (no answer within 5 s). A retry passed.
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/mediumowner/agentpriority/p2-mediumscope/roadmapsource/agentstatus/readytype/chorevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions