Skip to content

perf(roadmap): parse only the bodies that hold a job record #4445

Closed

Description

@dan-petty

Problem or Motivation

Each devops roadmap intake run lists every issue and pull request of the repository (4,431 entries), and split_record parses each body with markdown-it to find the job record block at its end. In three profiled --plan runs (#4404), this parse took 92 s, 68 s and 140 s (under cProfile). Offline, on one copy of the 4,431 bodies and with no other load, it takes 39.4 s.

Only 1,084 of the 4,431 bodies hold the record marker <!-- devops-roadmap-record . A body without the marker can have no record block, but the code parses it fully. The code also runs the inline parse of each body, but it reads only the top-level block tokens (level, type, map).

Proposed Solution & Architectural Design

In src/devops_cli/roadmap/stores/store.py:

  1. split_record returns the body and an empty record, with no parse, when the body does not hold the marker. _RECORD_BLOCK can only match text that holds the marker, so the result does not change.
  2. _BODY_MARKDOWN disables the core inline rule of markdown-it. The block tokens that _record_block_span reads come from the block parser, so the span does not change.

Offline measurement on the 4,431 real bodies: 39.4 s today, 11.1 s with both changes. The spans are the same on all 4,431 bodies. The contract tests of #2538 (tests/roadmap/stores/test_roadmap_store_contract.py) hold the behavior.

Target: the whole intake call takes 1 minute or less (#4404). This item cuts the body parse to 12 s or less offline. The listing item and the embedding item cut the rest.

Target Subsystem

roadmap

Existing Tool Considered

markdown-it-py is already the parser. MarkdownIt.disable("inline") is its public API to skip a core rule. This change adds no library. Cost: about 15,000 tokens to build, about 1,000 tokens a year to keep, and about 1 hour of elapsed time.

Source: #4404

Proposed design

Problem statement

Each devops roadmap intake run lists 4,431 issues and pull requests. It parses every body with markdown-it to find the job record block at its end. Only 1,084 bodies hold the record marker, but the code parses all of them fully, the inline rule included. Offline, on one copy of the bodies, the parse takes 39.4 s. The change cuts it to 11.1 s.

Acceptance criteria

Requirement: Skip the parse of a body with no marker

split_record SHALL return the body and an empty record without a markdown parse when the body holds no &lt;!-- devops-roadmap-record marker.

Scenario: A body without the marker

  • WHEN a test replaces _BODY_MARKDOWN with a parser that counts each call and calls split_record on a body that holds no marker
  • THEN the counter reads 0, and the function returns the body unchanged with an empty record.

Requirement: The body parse builds no inline tokens

_BODY_MARKDOWN MUST disable the inline core rule, so a parse builds block tokens only.

Scenario: A paragraph parse

  • WHEN a test parses the text Plain text. with _BODY_MARKDOWN
  • THEN the first token has the type paragraph, and its children is None.

Requirement: A record block at the end reads as before

split_record MUST return the same body text and record for a body that holds a record block at its end.

Scenario: A record block after a separator

  • WHEN a test calls split_record on Text\n\n&lt;!-- devops-roadmap-record {"Priority": "P2-Medium"} -->
  • THEN the returned text is Text, and the record holds {"Priority": "P2-Medium"}.

Requirement: A quoted marker stays in the body

split_record MUST keep a marker that a code span, a fenced code block, an indented code block or a following paragraph quotes in the body.

Scenario: A quote in a fenced code block

  • WHEN a test calls split_record on a body whose last block is a fence that quotes the marker
  • THEN the returned text is the whole body, the record is empty, and no warning is logged.

Requirement: The parse runs only for the bodies that hold the marker

split_record MUST call the markdown parse at most once for each body that holds the marker.

Scenario: A batch of mixed bodies

  • WHEN a test passes 100 bodies, of which 10 hold the marker, to split_record with a parser that counts each call
  • THEN the counter reads 10.

Requirement: The contract cases of the record block pass

The contract cases of the record block MUST pass with no change to their test code.

Scenario: The contract suite of the store

  • WHEN a test run collects tests/roadmap/stores/test_roadmap_store_contract.py
  • THEN every case passes with no failure.

Existing Tool Considered

No alternatives check has run. markdown-it-py is already the parser in src/devops_cli/roadmap/stores/store.py. MarkdownIt.disable("inline") is its public API to skip a core rule. The change adds no library, and the tool lacks nothing for this need. Written cost: about 15,000 tokens to build, about 1,000 tokens a year to keep, and about 1 hour of elapsed time.

Key questions

  • How does split_record skip the parse of a body with no record block?: Return the body and an empty record before the parse when the body holds no &lt;!-- devops-roadmap-record marker. _RECORD_BLOCK needs that marker, so a body without it can hold no block, and the result does not change. (best practice) [sources: src/devops_cli/roadmap/stores/store.py:644, src/devops_cli/roadmap/stores/store.py:688, src/devops_cli/roadmap/stores/store.py:689]
    • Chosen: Return early when the marker is absent. _RECORD_BLOCK can match only text with the marker, so the result is the same, and 3,347 of the 4,431 bodies skip the parse.
    • Rejected: Parse every body and then check the span. It keeps the 39.4 s cost on the bodies that hold no record.
    • Rejected: Cache the parse result by the hash of the body. It adds a cache to keep, and it does not cut the first parse.
  • Which markdown-it core rule skips the inline parse and keeps the block tokens?: Disable the core rule inline on _BODY_MARKDOWN with MarkdownIt.disable("inline"). The block rule still gives the top-level tokens, and _record_block_span reads only their level, type and map. (best practice) [sources: src/devops_cli/roadmap/stores/store.py:650, src/devops_cli/roadmap/stores/store.py:669]
    • Chosen: Disable the inline core rule. It is public API, and the block tokens that the span reads do not change.
    • Rejected: Keep every core rule. It keeps the inline parse of 4,431 bodies, which the change exists to remove.
    • Rejected: Replace markdown-it-py with a hand-written scan of the last block. It adds code to keep and risks a change on code spans, fences and quotes.
  • Do the tokens that _record_block_span reads come from the block parser?: Yes. _record_block_span reads level, type and map of the top-level tokens. The block rule sets them, and the inline rule fills only the children of a paragraph. [sources: src/devops_cli/roadmap/stores/store.py:669, src/devops_cli/roadmap/stores/store.py:673, src/devops_cli/roadmap/stores/store.py:650]
  • Which tests hold the behavior of the record block?: tests/roadmap/stores/test_roadmap_store_contract.py holds the cases of fix(roadmap): the job record reader takes a record block quoted in a code span as the record, and the next write deletes the quote #2538: a code span, a fence, an indented code block and a comment in the middle stay in the body, and a broken block reads as an empty record. [sources: tests/roadmap/stores/test_roadmap_store_contract.py]
  • Does the change need a new library or a new parser version?: No. markdown-it-py is already the parser, and MarkdownIt.disable is its public API. The change edits src/devops_cli/roadmap/stores/store.py only. [sources: src/devops_cli/roadmap/stores/store.py:650]
  • How does a test check the parse cost with no timing test?: Count the calls of the parser. A body that holds no marker gives no call, and a body that holds the marker gives one call. A wall-clock threshold is not a check, because it fails on a busy runner. (best practice) [sources: src/devops_cli/roadmap/stores/store.py:688, tests/roadmap/stores/test_roadmap_store_contract.py]
    • Chosen: Count the parser calls. The count is deterministic, and it states the saving of the change.
    • Rejected: Assert a wall-clock threshold on a body set. The result moves with the load of the runner, so the check is flaky.
    • Rejected: Read a profile by hand. A person does it once, so it is no check of a later change.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    on Nov 11, 2026
  2. added
    type/infra
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  3. 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/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. It cuts a 39 s parse to 11 s, a meaningful speedup, but the intake still works without it.
    • Value: Medium. It removes 28 s of wasted parse time from every intake run of 4,431 bodies.
    • Effort: Low. Two small edits in one file, estimated at about 1 hour of elapsed time.
    • Related: fix(roadmap): the job record reader takes a record block quoted in a code span as the record, and the next write deletes the quote #2538, which asks for a different change. Both touch split_record in store.py, but #2538 fixes a misidentification bug while this candidate skips parsing for bodies without the marker.
  4. added
    priority/p2-medium
    owner/agent
    on Nov 11, 2026
  5. added
    status/ready
    and removed
    status/new
    on Nov 11, 2026
  6. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 3180bf1 (see proposed design in issue body).

  7. added
    status/in-progress
    and removed
    status/ready
    on Nov 11, 2026
  8. removed
    status/in-progress
    owner/agent
    on Nov 11, 2026
  9. added a commit that references this issue on Nov 11, 2026
    c653bde
  10. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor
  11. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-11 05:46 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/roadmapsource/agenttype/infravalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions