Skip to content

improve: reduce hot-path linear scans and redundant I/O - #95697

Merged
vincentkoc merged 2 commits into
mainfrom
codex/perf-hot-paths
Jun 23, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
codex/perf-hot-paths

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Several high-frequency paths repeatedly scanned arrays, moved worklists from the front, or re-read filesystem metadata. Those patterns made common workloads quadratic or multiplied I/O as transcript, stream, media, and memory data grew.

Why This Change Was Made

  • process markdown chunk worklists as stacks instead of repeated shift/unshift
  • retain tool-block indexes while streaming instead of calling indexOf for each fragment
  • tail-scan modern parent-linked transcripts and preserve the full scan for legacy/mixed files
  • reuse loaded image buffers and dimensions instead of re-reading metadata
  • resolve local media roots once per attachment batch, after managed inbound exemptions
  • deduplicate repeated short-term memory source checks within a promotion batch

The changes keep ordering, validation, legacy behavior, and transport semantics intact. No speculative persistence/index format was added.

User Impact

Large markdown responses, parallel tool streams, long transcripts, image batches, and repeated memory sources do less redundant work. The expected result is lower CPU and filesystem overhead on these hot paths without changing output or security boundaries.

Evidence

  • focused Vitest run: 6 shards, 555 tests passed on the exact PR tree
  • follow-up SDK surface, plugin contract, and media checks passed
  • oxfmt --check and git diff --check passed
  • fresh autoreview: clean, overall patch correctness 0.86
  • markdown benchmark with 50,000 chunks: approximately 263 ms baseline versus 69 ms after the worklist change
  • transcript benchmark with 20,000 parent-linked entries: approximately 42 ms baseline versus 22 ms after the tail scan
  • hosted CI run 27948310315 passed all 50 jobs before the latest mainline-only rebase
  • hosted CI run 27948998212 has 49 passing jobs; its only failure is three untouched src/gateway/server.cron.test.ts tests, reproduced on exact origin/main at f40071cc

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime extensions: memory-core Extension: memory-core agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jun 22, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review June 22, 2026 07:54
@vincentkoc
vincentkoc force-pushed the codex/perf-hot-paths branch 2 times, most recently from 60fc6ae to 8d3119d Compare June 22, 2026 08:36
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Jun 22, 2026
@vincentkoc
vincentkoc force-pushed the codex/perf-hot-paths branch from 7958128 to 8985aab Compare June 22, 2026 09:03
@openclaw-barnacle openclaw-barnacle Bot removed the commands Command implementations label Jun 22, 2026
@vincentkoc
vincentkoc force-pushed the codex/perf-hot-paths branch from 8985aab to bec3231 Compare June 22, 2026 09:15
@vincentkoc
vincentkoc requested review from a team as code owners June 22, 2026 10:53
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: googlechat Channel integration: googlechat channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: whatsapp-web Channel integration: whatsapp-web app: web-ui App: web-ui cli CLI command changes scripts Repository scripts commands Command implementations extensions: vercel-ai-gateway extensions: codex channel: synology-chat extensions: oc-path extensions: vllm size: XL and removed size: M labels Jun 22, 2026
@vincentkoc
vincentkoc force-pushed the codex/perf-hot-paths branch from 3b7e8f5 to 53f6452 Compare June 23, 2026 01:54
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation channel: discord Channel integration: discord channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams labels Jun 23, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @vincentkoc!

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

Labels

agents Agent runtime and tooling extensions: memory-core Extension: memory-core extensions: qa-lab gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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