Repository navigation
perf(streaming): cut bundle, Markdown, and protocol overhead - #91
Merged
Merged
Conversation
added 14 commits
November 30, 2026 20:25
Split Markdown at blank lines outside fenced code blocks and cache parsed blocks in a bounded locale- and handler-aware LRU so streaming appends only re-parse the trailing block. Stabilize MessageBubble link callbacks so memoized bubbles skip re-parsing on unrelated renders.
…istrations Prune removed roster agents on explicit agentIds updates, prune removed conversations on full conversationMap sync, and keep only the latest standalone session pin per agent while preserving watermarks for surviving cursors. Incremental ensureWatch calls from sendMessage, listAgents, and listTranscriptEntries keep unrelated watches intact.
Owner
Author
Benchmark evidence (median of 5 interleaved A/B pairs,
|
| Metric | Before (85a38f1) median ms (range) |
After median ms (range) | Delta |
|---|---|---|---|
connect_2mib_frame_ms (2 MiB frame in 1 KiB chunks) |
110.84 (99.30..125.18) | 26.91 (22.47..31.11) | -75.7% |
connect_stream_300_frames_ms |
2.32 (1.85..2.62) | 1.81 (1.46..2.67) | -21.9% |
markdown_rerender_40x_ms (40 full SSR renders) |
26.20 (23.95..26.54) | 20.78 (18.29..27.29) | -20.7% |
markdown_stream_80_steps_ms (full SSR stream) |
41.40 (40.81..47.56) | 38.52 (32.70..50.17) | -6.9% (ranges overlap) |
| Markdown parser-only, 80 stream steps (excludes SSR string serialization) | 8.73 (8.51..9.20) | 3.67 (3.58..3.88) | -58.0% |
Limiter notes (benchmark-checklist):
connect_2mib_frame_mswas bound by O(N²)Buffer.concatper 1 KiB read; reassembling once per frame removed it (non-overlapping ranges).- Full SSR
markdown_stream_80_steps_msis floored byrenderToStaticMarkupre-serializing the entire report to an HTML string on every step. In the mounted app, unchanged<Fragment>blocks keep referential equality so React skips both parsing and subtree reconciliation;useMemo+ stableMessageBubblecallbacks also skip work on unrelated parent renders.
Production bundle bytes (npm run build)
| Artifact | Before | After | Delta |
|---|---|---|---|
Renderer entry index-*.js |
2,048.81 kB | 729.07 kB | -64.4% |
Main out/main/index.js |
1,556.89 kB | 857.03 kB | -45.0% |
Preload out/preload/index.js |
24.96 kB | 14.99 kB | -39.9% |
| Total JS across all chunks | 5,055.97 kB | 2,653.58 kB | -47.5% |
Owner
Author
|
PASS+NOTES Independent pre-merge verification of Commands and results
What a user would notice
Non-blocking notes
|
Merged
GOXF
added a commit
to GOXF/botark
that referenced
this pull request
Nov 30, 2026
* 修复 Grok Bot 实时回复及历史补取 * 让 Grok 群聊实时接收回复和文件 * feat(portable): add portable data directory and Windows portable package Resolve userData at startup in order of --user-data-dir, PORTABLE_EXECUTABLE_DIR, a sibling BotArkData folder or .botark-portable marker, legacy bothub migration, then the default userData path. Verify portable writability with a probe file and fall back to the default userData with a warning when read-only. Add the Windows portable target (BotArk-Portable-<version>-<arch>.exe) alongside NSIS, and document portable mode. Closes qybaihe#87 * test(portable): use cross-platform read-only fallback fixtures on Windows * perf(streaming): cut bundle, Markdown, and protocol overhead (qybaihe#91) * test(bench): add production-mode streaming and protocol benchmarks * test(chat): pin MarkdownText rendering and handler behavior * perf(chat): cache completed Markdown blocks during streaming Split Markdown at blank lines outside fenced code blocks and cache parsed blocks in a bounded locale- and handler-aware LRU so streaming appends only re-parse the trailing block. Stabilize MessageBubble link callbacks so memoized bubbles skip re-parsing on unrelated renders. * perf(build): minify production main, preload, and renderer bundles * perf(renderer): load InfoPanel on demand and add Electron smoke check * fix(grok): bound watch frame size and avoid quadratic buffering * fix(dsbot): deduplicate concurrent relay connects and close stale flights * fix(mcp): clear connect timeout before paginated tools/list discovery * perf(rooms): debounce room persistence and cancel pending writes on clear * perf(vault): inspect macOS code signature asynchronously * fix(grok): prune stale watch cursors without dropping incremental registrations Prune removed roster agents on explicit agentIds updates, prune removed conversations on full conversationMap sync, and keep only the latest standalone session pin per agent while preserving watermarks for surviving cursors. Incremental ensureWatch calls from sendMessage, listAgents, and listTranscriptEntries keep unrelated watches intact. * test: fix strict TypeScript signatures in vault and room persistence tests * style(dsbot): drop redundant relay reuse comment * docs(changelog): document streaming, bundle, and protocol stability improvements --------- Co-authored-by: 张少谦 <zhangshaoqian@moonshot.ai> * chore(release): bump BotArk to v0.18.0 --------- Co-authored-by: rainhan99 <16128160+rainhan99@users.noreply.github.com> Co-authored-by: Timo Zhang <qybaihe@gmail.com> Co-authored-by: 张少谦 <zhangshaoqian@moonshot.ai>
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.
Why
Goal: rigorously measure and reduce BotArk's startup, streaming, and protocol stability bottlenecks, building on the merged Grok reply-delivery fix (#89) and portable packages (#90).
What changed
build.minifyfor main, preload, and renderer (electron-vitedefaults to unminified output), and lazy-loadedInfoPanelplus its platform inspectors on first open. Total JS dropped from 5.06 MB to 2.65 MB (-47.6%).MarkdownTextcaches completed blocks split at blank lines outside fenced code blocks in a bounded, locale- and handler-aware cache, andMessageBubblepasses stable callbacks. Parser-only time across 80 incremental renders of a 30-section report fell from 8.73 ms to 3.67 ms (-58.0%, median of 5 interleaved A/B pairs).pagehide, and cancel queued writes when clearing data.watchTranscripts: 4 MiB frame cap + single-copy frame reassembly instead of per-readBuffer.concat.grokWatchManager: prune removed roster/conversation cursors while preserving incremental watch registrations.ensureRelayClientand probes, closing superseded sockets.tools/list.codesigninspection instead of blockingspawnSync(up to 3.5 s).Scope
Renderer chat/room hot paths, Electron build config, Grok/DS Bot/MCP transports, and vault/updater signature check. Added
scripts/bench/andscripts/smoke/electron-smoke.mjs.Tradeoffs
MarkdownTextkeeps a bounded 400-block cache to make both streaming appends and remounts cheap; keys include locale and per-instance handler IDs so cached nodes never leak stale closures across chats.renderToStaticMarkupre-serializes the whole tree each step; parser-only and interleaved A/B numbers are reported separately.Blast Radius
No IPC or persisted-schema changes. Default installs, auto-update manifests, and platform wire formats are unchanged.
Verification
npm run typecheck,npx vitest run(109 files),npx vitest run --config vitest.e2e.config.mts(76 tests): all pass.npm run build+node scripts/smoke/electron-smoke.mjs: real Electron production boot with 0 exceptions and 0 console errors;InfoPanelchunk loads only on open.node scripts/bench/run.mjsandnode scripts/bench/compare.mjs(frozen harness SHA-256 verified, 5 interleaved A/B pairs, 0 errors; results table in PR comment).