perf(slack): narrow runtime-setter specifier to avoid loading 284KB barrel#69325
Closed
amknight wants to merge 1 commit into
Closed
perf(slack): narrow runtime-setter specifier to avoid loading 284KB barrel#69325amknight wants to merge 1 commit into
amknight wants to merge 1 commit into
Conversation
…arrel The slack extension's BundledChannelEntryContract pointed its `runtime` specifier at `./runtime-api.js` — a barrel module that re-exports the full slack runtime surface (29 chunks, ~284KB). The framework calls `setChannelRuntime` synchronously during `register()`, so this barrel was loaded on every gateway startup just to obtain the 23-line `setSlackRuntime` setter function. Add a narrow `runtime-setter-api.ts` entry point that re-exports only `setSlackRuntime`, and point the contract at it. The full runtime-api tree is still loaded — but only when an actual slack message arrives, not during register(). Refs #68983, #65444
This was referenced Apr 20, 2026
Member
Author
|
Combined into #69317 — that PR now contains this commit (rebased onto current Note: the rebase dropped a stray |
amknight
added a commit
that referenced
this pull request
Apr 20, 2026
…loading runtime barrel The slack extension's `registerFull` callback in `extensions/slack/index.ts` loaded `./runtime-api.js` synchronously to obtain `registerSlackPluginHttpRoutes`. That barrel re-exports the entire slack runtime surface (~284KB, 13 chunks), so every gateway startup paid that cost just to register a few HTTP routes. This is the same problem #69325 fixed for `setSlackRuntime` — but the `registerFull` path was overlooked, so the cost simply shifted from `setChannelRuntime` (~13s) to `registerFull` (~8s) once #69325 landed. Add a narrow `http-routes-api.ts` entry point that re-exports only `registerSlackPluginHttpRoutes`, and point `extensions/slack/index.ts` at it. The narrow entry only pulls in `accounts`, `paths`, and the `account-id` SDK module — three chunks instead of thirteen. Per-step cold-start measurement (gateway with all three commits): bundled-register:setChannelRuntime 812ms (was 13183ms) bundled-register:loadChannelPlugin 5057ms (unchanged) slack:registerFull:loadHttpRoutesExport 80ms (was 8389ms) TOTAL slack register() 5956ms (was 14102ms, -8.1s, -58%) Refs #68983, #65444.
amknight
added a commit
that referenced
this pull request
Apr 20, 2026
…loading runtime barrel The slack extension's `registerFull` callback in `extensions/slack/index.ts` loaded `./runtime-api.js` synchronously to obtain `registerSlackPluginHttpRoutes`. That barrel re-exports the entire slack runtime surface (~284KB, 13 chunks), so every gateway startup paid that cost just to register a few HTTP routes. This is the same problem #69325 fixed for `setSlackRuntime` — but the `registerFull` path was overlooked, so the cost simply shifted from `setChannelRuntime` (~13s) to `registerFull` (~8s) once #69325 landed. Add a narrow `http-routes-api.ts` entry point that re-exports only `registerSlackPluginHttpRoutes`, and point `extensions/slack/index.ts` at it. The narrow entry only pulls in `accounts`, `paths`, and the `account-id` SDK module — three chunks instead of thirteen. Per-step cold-start measurement (gateway with all three commits): bundled-register:setChannelRuntime 812ms (was 13183ms) bundled-register:loadChannelPlugin 5057ms (unchanged) slack:registerFull:loadHttpRoutesExport 80ms (was 8389ms) TOTAL slack register() 5956ms (was 14102ms, -8.1s, -58%) Refs #68983, #65444.
amknight
added a commit
that referenced
this pull request
Apr 21, 2026
…loading runtime barrel The slack extension's `registerFull` callback in `extensions/slack/index.ts` loaded `./runtime-api.js` synchronously to obtain `registerSlackPluginHttpRoutes`. That barrel re-exports the entire slack runtime surface (~284KB, 13 chunks), so every gateway startup paid that cost just to register a few HTTP routes. This is the same problem #69325 fixed for `setSlackRuntime` — but the `registerFull` path was overlooked, so the cost simply shifted from `setChannelRuntime` (~13s) to `registerFull` (~8s) once #69325 landed. Add a narrow `http-routes-api.ts` entry point that re-exports only `registerSlackPluginHttpRoutes`, and point `extensions/slack/index.ts` at it. The narrow entry only pulls in `accounts`, `paths`, and the `account-id` SDK module — three chunks instead of thirteen. Per-step cold-start measurement (gateway with all three commits): bundled-register:setChannelRuntime 812ms (was 13183ms) bundled-register:loadChannelPlugin 5057ms (unchanged) slack:registerFull:loadHttpRoutesExport 80ms (was 8389ms) TOTAL slack register() 5956ms (was 14102ms, -8.1s, -58%) Refs #68983, #65444.
amknight
added a commit
that referenced
this pull request
Apr 22, 2026
…loading runtime barrel The slack extension's `registerFull` callback in `extensions/slack/index.ts` loaded `./runtime-api.js` synchronously to obtain `registerSlackPluginHttpRoutes`. That barrel re-exports the entire slack runtime surface (~284KB, 13 chunks), so every gateway startup paid that cost just to register a few HTTP routes. This is the same problem #69325 fixed for `setSlackRuntime` — but the `registerFull` path was overlooked, so the cost simply shifted from `setChannelRuntime` (~13s) to `registerFull` (~8s) once #69325 landed. Add a narrow `http-routes-api.ts` entry point that re-exports only `registerSlackPluginHttpRoutes`, and point `extensions/slack/index.ts` at it. The narrow entry only pulls in `accounts`, `paths`, and the `account-id` SDK module — three chunks instead of thirteen. Per-step cold-start measurement (gateway with all three commits): bundled-register:setChannelRuntime 812ms (was 13183ms) bundled-register:loadChannelPlugin 5057ms (unchanged) slack:registerFull:loadHttpRoutesExport 80ms (was 8389ms) TOTAL slack register() 5956ms (was 14102ms, -8.1s, -58%) Refs #68983, #65444.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The slack extension's
BundledChannelEntryContractpointed itsruntimespecifier at./runtime-api.js— a barrel module that re-exports the full slack runtime surface (29 chunks, ~284KB). The framework callssetChannelRuntimesynchronously duringregister(), so this barrel was loaded on every gateway startup just to obtain the 23-linesetSlackRuntimesetter function.This PR adds a narrow
runtime-setter-api.tsentry point that re-exports onlysetSlackRuntime, and points the contract at it. The full runtime-api tree is still loaded — but only when an actual slack message arrives, not duringregister().Changes
extensions/slack/runtime-setter-api.ts— 3 lines, re-exportssetSlackRuntimeonlyextensions/slack/index.ts— pointruntime.specifierat the new narrow entryextensions/slack/package.json— add the new entry to theopenclaw.extensionsbundle listProfiling
Built into a production-style
dist/. Measured via per-plugin profiler and gateway ready time on macOS, Node v24.register()runtime-setter-api.js(orruntime-api.js) tree size(Per-extension benefits are partial — the dominant slack startup cost remains
loadChannelPlugin()which is being addressed separately by the framework-level lazy registration work in #65444. This PR removes one of the redundant module loads.)Related work
buildPluginLoaderAliasMapto enable jiti sentinel reuse (cross-cutting framework fix; complements this PR)Pattern
Same pattern Peter has been applying to other modules:
805481c176perf: narrow bonjour and sqlite runtime type surfacesa0919685beperf: narrow local llama type surface346aa0ed47perf: narrow HTML parser type surface1f71137d1eperf: narrow PDF extractor type surfaceCould be applied to other channel extensions (telegram, whatsapp, discord) that also have heavy
runtime-apibarrels.