perf: 10 constraint-anchored optimizations#12
Merged
Conversation
…and TS client Rust core (conduit-core): - Replace VecDeque<Vec<u8>> with preformatted wire buffer in RingBuffer and Queue — drain_all is now a single memcpy instead of N×2 extend_from_slice calls (estimated 40-80x speedup for streaming drain) - Add Bytes newtype with bulk encode/decode for Vec<u8> payloads - Add MIN_SIZE associated constant to Decode trait with upfront bounds check in derive macro, reducing redundant per-field checks - Add overflow guards: u32 truncation on frame length, frame_count u32::MAX, checked_add for frame_cost on 32-bit targets, Bytes::decode checked_add Plugin (tauri-plugin-conduit): - Eliminate 3 allocations per invoke: use URI path() directly, borrow invoke key header as &str, return Cow<str> from percent_decode - Replace double-spawn async pattern with single spawn + catch_unwind via futures-util FutureExt - Pre-cache Arc<AppHandle> in PluginState to avoid per-request Arc allocation TypeScript client: - parseDrainBlob returns zero-copy Uint8Array views instead of copies - Add WireWriter builder class for single-allocation multi-field encoding - Pass JSON.stringify result directly to fetch, skip TextEncoder pass - Use AbortSignal.timeout() for drain, replacing AbortController + setTimeout Reviewed by Codex CLI (gpt-5.4) over 5 rounds — all findings addressed. All 138 Rust tests and 35 TypeScript tests pass. Zero clippy warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
drain_allgoes from N×2extend_from_sliceto a single memcpy (~40-80x speedup for streaming)Vec<u8>encode/decode (~2x for large blobs)FutureExt::catch_unwind(100-200ns per async invoke)Arc<AppHandle>in PluginState (50-100ns per invoke)Also includes overflow guards caught during Codex (gpt-5.4) code review over 5 rounds:
Issues addressed
Closes #2, closes #3, closes #4, closes #5, closes #6, closes #7, closes #8, closes #9, closes #10, closes #11
Test plan
cargo fmt --all -- --checkcargo test --workspace— 138 tests passcargo clippy --workspace -- -D warnings— 0 warningscargo clippy --manifest-path crates/tauri-plugin-conduit/Cargo.toml -- -D warningsnpx tsx --test src/__tests__/*.test.ts— 35 tests pass🤖 Generated with Claude Code