Skip to content

perf(slack): reduce message hot-path overhead#78746

Merged
vincentkoc merged 5 commits into
mainfrom
perf/slack-message-hotpath
May 7, 2026
Merged

perf(slack): reduce message hot-path overhead#78746
vincentkoc merged 5 commits into
mainfrom
perf/slack-message-hotpath

Conversation

@vincentkoc
Copy link
Copy Markdown
Member

@vincentkoc vincentkoc commented May 7, 2026

Summary

  • Cherry-picks the Slack message hot-path perf slice from perf/telegram-slack-rtt-20260503.
  • Reduces Slack message preparation allocations, caches native stream recipient team lookups, reuses thread-participation state, and trims thread-context history retention work.
  • Adds a changelog note for the Slack reply hot-path performance improvement.

Source commits:

Verification

  • Crabbox tbx_01kr06bg73x3mk2vfrrv3076jr: pnpm test extensions/slack/src/monitor/message-handler/dispatch.streaming.test.ts extensions/slack/src/monitor/message-handler/dispatch.preview-fallback.test.ts extensions/slack/src/monitor/message-handler/prepare.test.ts extensions/slack/src/monitor/message-handler/prepare-thread-context.test.ts extensions/slack/src/monitor/message-handler/prepare.thread-session-key.test.ts extensions/slack/src/monitor/message-handler.test.ts extensions/slack/src/monitor/replies.test.ts extensions/slack/src/monitor/monitor.thread-resolution.test.ts extensions/slack/src/monitor.threading.missing-thread-ts.test.ts extensions/slack/src/threading.test.ts (10 files, 149 tests)
  • Crabbox tbx_01kr06dbjf7z4ajch55jjn3q47: pnpm check:changed (extensions + extensionTests lanes)
  • Crabbox tbx_01kr06p31mkhvzpj70s162fcex: pnpm test extensions/slack (91 files, 925 tests)
  • Mantis Slack Desktop Smoke / Crabbox AWS: slack-canary passed against d7a8201b0510c53d4477efe1104bc0dc92b33f68 in https://github.com/openclaw/openclaw/actions/runs/25474033044 (artifact https://github.com/openclaw/openclaw/actions/runs/25474033044/artifacts/6846354538)
  • Mantis Slack Desktop Smoke / Crabbox Hetzner: slack-thread-follow-up passed against d7a8201b0510c53d4477efe1104bc0dc92b33f68 in https://github.com/openclaw/openclaw/actions/runs/25475954203 (artifact https://github.com/openclaw/openclaw/actions/runs/25475954203/artifacts/6847037521)
  • git diff --check origin/main...HEAD
  • pnpm check:changelog-attributions

Note: an intermediate AWS retry for slack-thread-follow-up was canceled after Crabbox AWS bootstrap/quota fallback never reached Slack; the same scenario passed on Hetzner and is the counted thread-path proof.

@vincentkoc vincentkoc self-assigned this May 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: M maintainer Maintainer-authored PR labels May 7, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 7, 2026

Codex review: needs maintainer review before merge.

Summary
The PR optimizes Slack message hot paths by reducing allocation work, caching native stream recipient team lookups, avoiding redundant thread participation lookups, trimming thread-context retention work, and adding Slack tests plus a changelog entry.

Reproducibility: not applicable. this is a performance-focused PR rather than a reported functional bug. The review path is source/diff inspection plus the PR's targeted Slack tests and live Slack QA artifacts.

Real behavior proof
Not applicable: Not applicable for a MEMBER-authored PR; the PR nevertheless includes Mantis Slack Desktop Smoke artifacts and reported Crabbox validation.

Next step before merge
This is a draft, maintainer-labeled MEMBER PR with no narrow automated repair; maintainer review should decide when it is ready to merge.

Security
Cleared: The diff only changes Slack plugin source/tests and the changelog, with no workflow, dependency, lockfile, secret-handling, or package-resolution changes.

Review details

Best possible solution:

Keep the Slack-owned optimization path, preserve the attached live Slack QA evidence, and merge after the maintainer intentionally exits draft and completes review.

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

Not applicable: this is a performance-focused PR rather than a reported functional bug. The review path is source/diff inspection plus the PR's targeted Slack tests and live Slack QA artifacts.

Is this the best way to solve the issue?

Yes, with the maintainer-review caveat: the changes stay inside the Slack plugin, avoid core or SDK contract changes, and add focused coverage. The safest path is to finish normal maintainer review before merging the draft PR.

What I checked:

  • Live PR state: GitHub API reports this PR is open, draft, mergeable, authored by a MEMBER, and labeled maintainer, channel: slack, and size: M; protected maintainer handling prevents cleanup closure. (d7a8201b0510)
  • Current stream recipient path: Current main resolves the Slack native stream recipient team with users.info on the stream-start path and falls back to the monitor team; the PR adds a bounded per-user/team cache around this lookup. (extensions/slack/src/monitor/message-handler/dispatch.ts:222, 6009b86f0de4)
  • Current mention/thread participation path: Current main checks subteam mention membership without a cheap marker guard and calls persisted thread-participation lookup for eligible thread replies before the PR narrows that work. (extensions/slack/src/monitor/message-handler/prepare.ts:289, 6009b86f0de4)
  • Current thread-context allocation path: Current main resolves user names for every retained non-current-bot thread history item before filtering, and trims retained thread history with per-message shift() work; the PR limits and narrows those operations. (extensions/slack/src/monitor/message-handler/prepare-thread-context.ts:177, 6009b86f0de4)
  • PR diff scope: The patch touches only CHANGELOG.md and Slack plugin monitor source/tests: dispatch.ts, prepare-content.ts, prepare-thread-context.ts, prepare.ts, thread.ts, and dispatch.streaming.test.ts. (d7a8201b0510)
  • Verification evidence: The PR body lists targeted Slack message-handler tests, pnpm check:changed, full pnpm test extensions/slack, diff/changelog checks, and Mantis Slack Desktop Smoke proof; the published Mantis report for slack-thread-follow-up says Status: pass. (d7a8201b0510)

Likely related people:

  • vincentkoc: The PR source commits are authored by vincentkoc, and recent current-main Slack progress/draft history also includes Slack-adjacent work by the same maintainer. (role: recent Slack performance contributor; confidence: high; commits: 9962328b7cf0, 8ce7cc8aae5b, 098a8b34b9aa; files: extensions/slack/src/monitor/message-handler/dispatch.ts, extensions/slack/src/monitor/message-handler/prepare.ts, extensions/slack/src/monitor/message-handler/prepare-content.ts)
  • steipete: Recent GitHub file history shows multiple current-main Slack monitor and message lifecycle changes by steipete across the central files this PR changes. (role: recent Slack channel maintainer; confidence: high; commits: 05eda57b3c72, fa689295c649, b5d408cd690f; files: extensions/slack/src/monitor/message-handler/dispatch.ts, extensions/slack/src/monitor/message-handler/prepare.ts, extensions/slack/src/monitor/message-handler/prepare-thread-context.ts)
  • amknight: The optimized thread-participation lookup path is adjacent to amknight's merged Slack thread participation persistence work. (role: introduced adjacent behavior; confidence: medium; commits: d0ec3d1f09b0; files: extensions/slack/src/monitor/message-handler/prepare.ts)
  • jacobtomlinson: The PR changes the thread-context filtering/allocation path that GitHub history links to prior Slack room thread allowlist filtering work by jacobtomlinson. (role: introduced adjacent thread-context filtering; confidence: medium; commits: ac5bc4fb37be; files: extensions/slack/src/monitor/message-handler/prepare-thread-context.ts)

Remaining risk / open question:

  • I did not run tests in this read-only sweep; validation relies on the PR body, published Mantis artifacts, and source/diff inspection.
  • The PR is still draft and protected by the maintainer label, so merge timing remains a maintainer decision.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 6009b86f0de4.

@openclaw-mantis
Copy link
Copy Markdown

openclaw-mantis Bot commented May 7, 2026

Mantis Slack Desktop Smoke QA

Summary: Mantis ran Slack QA inside a Crabbox Linux VNC desktop, started an OpenClaw Slack gateway in that VM, opened Slack Web in the visible browser, and captured screenshot/video evidence.

Slack desktop/VNC browser

Slack Web desktop screenshot from the Mantis VM

Slack motion preview

Animated Slack desktop preview

Motion-trimmed clips:

Full videos:

Raw QA files: https://github.com/openclaw/openclaw/tree/qa-artifacts/mantis/slack-desktop-smoke/pr-78746/run-25475954203-1

@vincentkoc vincentkoc force-pushed the perf/slack-message-hotpath branch from d7a8201 to 5a67b57 Compare May 7, 2026 05:28
@vincentkoc vincentkoc merged commit 5a67b57 into main May 7, 2026
54 checks passed
@vincentkoc vincentkoc deleted the perf/slack-message-hotpath branch May 7, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant