Skip to content

improve: format long list-heavy reports faster - #145665

Merged
steipete merged 1 commit into
mainfrom
codex/perf-sep12-campaign
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-sep12-campaign

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where long reports with many separate lists take progressively longer to format for messaging channels.

Why This Change Was Made

The shared Markdown renderer only needs to know whether its output ends with two newlines. Check that suffix directly instead of searching the entire accumulated output after every top-level list. This preserves the existing separator behavior and removes repeated prefix scans.

User Impact

Large list-heavy responses spend less time in Markdown parsing. Formatting, Unicode offsets, and parser metadata remain unchanged.

Evidence

  • Windows x64, Node 26.8.2; actual markdownToIR source entry, ten warmups and thirty samples per fixed synthetic report. The 512-section / 225,575 UTF-16-unit workload improved from 323.50 ms to 136.90 ms median (2.36x). Smaller cases were noisy and do not establish a speedup.
  • Descriptor-inclusive output digests match at 32, 128, and 512 sections, including non-enumerable list and block metadata. Benchmark generation, hashing, and I/O were outside the timed interval.
  • Existing Markdown IR and nested-list suites: 54 tests passed. An additional exhaustive check of 19,531 suffix cases, including CR/LF and Unicode line separators, found identical separator decisions.
  • Source-performance build passed. Independent review found no actionable issues. Formatting, targeted lint, production core typecheck, and all core test typecheck shards passed. The original local changed-file check flagged canonicalProviderName in scripts/crabbox-wrapper-providers.mts despite existing external consumers; that export, its consumers, and Knip configuration were unchanged between original baseline7275b4baa025 and the tested patch.
  • Refreshed onto main after improve: avoid model-context worker startup delays in tests #145708 repaired the reproduced cold-worker CI failure. git range-diff confirms the Markdown patch is identical, and the measured candidate source hash remains unchanged. Fresh exact-head CI run34679693312 passed, including the originally failing shard.
  • Both Markdown suites passed again on refreshed commit d0068253c7866c20e0bc32c5205dad07db891f0d: 54 tests, Node 26.8.2, after repairing missing task-local dependency payloads. The checkout remains clean.
  • An independent isolated Gateway stress run (8 turns, 1,000 sessions, 100 updates, 540 history reads) exposed a session-list timeout. It does not establish an end-to-end speedup and is being investigated separately.

The benchmark artifact is local task evidence, not a new timing-sensitive CI assertion.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 12, 2026 05:51
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 3:17 AM ET / 07:17 UTC (Revision 4).

ClawSweeper review

What this changes

The shared Markdown renderer checks the last two characters directly when separating lists, reducing formatting work for long reports without changing their output.

Merge readiness

✅ Ready for maintainer review

This optimization remains useful: current main and the latest release retain the repeated regex scan. The replacement preserves separator behavior, and no actionable correctness or security defect was found.

Priority: P2
Reviewed head: d0068253c7866c20e0bc32c5205dad07db891f0d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving optimization supported by specific benchmark results and existing formatting coverage.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The external-contributor gate does not apply to this member-authored PR. Its body reports before/after measurements through the actual Markdown parser on Windows and matching output metadata; no independent benchmark execution was performed here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor gate does not apply to this member-authored PR. Its body reports before/after measurements through the actual Markdown parser on Windows and matching output metadata; no independent benchmark execution was performed here.
Evidence reviewed 8 items Verified introduced change: The pinned merge-base-to-head diff changes only the top-level list separator predicate. Both predicates append one newline exactly when fewer than two terminal newlines are present; list-item closing already ensures a trailing newline. The host-verified test merge also changes only this file relative to its main parent.
Current main still contains the scan: Fetched main retains the regex-based trailing-newline count, so it does not already contain this optimization.
Latest release comparison: The same regex implementation exists in v2026.9.4.
Findings None None.
Security None None.

How this fits together

OpenClaw parses outbound Markdown into text and formatting spans shared by channel renderers. List separators become part of that text before chunking and channel-specific formatting.

flowchart LR
  A[Outbound Markdown] --> B[Shared Markdown parser]
  B --> C[List closes]
  C --> D{Ends with two newlines?}
  D -->|No| E[Append one newline]
  D -->|Yes| F[Text and formatting spans]
  E --> F
  F --> G[Channel chunking and rendering]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -1. Total -1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 1 2 -1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 1 2 -1

Review metrics

Metric Value Why it matters
Reported parser benchmark 323.50 ms → 136.90 ms median; 2.36× The 512-section workload supports a parser-level benefit; smaller workloads and end-to-end delivery gains remain unproven.

Technical review

Best possible solution:

Keep the suffix check in the existing shared renderer, preserving list spacing and all downstream text offsets.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: each top-level list close searches the accumulated output with a regex on current main. The PR reports a matching large-report benchmark; this review did not execute it.

Is this the best way to solve the issue?

Yes. Testing the required suffix directly is a narrow replacement within the existing owner, with equivalent separator decisions and no new API or state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 69467d2ed8a5.

Labels

Label justifications:

  • P2: This addresses avoidable formatting latency for large list-heavy responses without changing user configuration or output.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor gate does not apply to this member-authored PR. Its body reports before/after measurements through the actual Markdown parser on Windows and matching output metadata; no independent benchmark execution was performed here.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff changes only the top-level list separator predicate. Both predicates append one newline exactly when fewer than two terminal newlines are present; list-item closing already ensures a trailing newline. The host-verified test merge also changes only this file relative to its main parent. (packages/markdown-core/src/ir.ts:686, d0068253c786)
  • Current main still contains the scan: Fetched main retains the regex-based trailing-newline count, so it does not already contain this optimization. (packages/markdown-core/src/ir.ts:686, 69467d2ed8a5)
  • Latest release comparison: The same regex implementation exists in v2026.9.4. (packages/markdown-core/src/ir.ts:686, 3a9d69db306c)
  • Existing observable formatting coverage: Read both Markdown IR and nested-list suites. Existing cases protect blank lines after ordered and bullet lists, absence of triple newlines, nested-list spacing, metadata, and UTF-16 boundaries. Tests were inspected, not executed during this read-only review. (packages/markdown-core/src/ir.nested-lists.test.ts, d0068253c786)
  • Shared renderer boundary: The documented pipeline parses Markdown into text and UTF-16 spans before channel rendering and chunking. The changed predicate operates on that local text; no Codex harness, provider protocol, persistent state, or authority contract is involved. Public docs: docs/concepts/markdown-formatting.md. (docs/concepts/markdown-formatting.md, d0068253c786)
  • Captured performance and validation evidence: The supplied complete PR body reports a Windows x64 Node 26.8.2 run through markdownToIR: 512 sections improved from 323.50 ms to 136.90 ms median, with descriptor-inclusive output digests matching at three sizes. It also reports 54 tests passing on the reviewed head and 19,531 equivalent suffix decisions. These are contributor-reported results; the local benchmark artifact was not supplied. The separately reported Gateway stress timeout does not establish a defect in this predicate or an end-to-end speedup. (d0068253c786)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-12T05:58:30.895Z sha c29cbc9 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T06:05:44.446Z sha c29cbc9 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-12T07:08:57.254Z sha d006825 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/perf-sep12-campaign branch from c29cbc9 to d006825 Compare September 12, 2026 07:02
@steipete
steipete merged commit 7ee4437 into main Sep 12, 2026
137 of 138 checks passed
@steipete
steipete deleted the codex/perf-sep12-campaign branch September 12, 2026 13:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant