Repository navigation
Reduce hot-path allocations in IPC, Lua, and metrics - #14
Merged
Merged
Conversation
Use one try_write_with entry point to encode into available queue space and observe publication before notification. Retain Source records across Full without an intermediate encoded buffer, encode completions in place, and copy existing egress bytes once per destination. Preserve atomic publication on encoder failure and cover Full, wraparound, callback ordering, crash recovery, and cross-process callers.
Gujiawei-Edinburgh
approved these changes
Oct 2, 2026
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.
This removes temporary buffers and redundant copies from message processing and metrics collection while preserving queue publication, completion ownership, metric values and output formats.
Changes
try_write_with(exact_len, encoder, on_committed). Source submissions and completions encode directly into available queue space; full queues retain the original record for retry. Egress builds one complete record and copies it to each destination queue.Rust API change:
try_writeandtry_write_observedare replaced bytry_write_with. Callers with encoded bytes copy them into the supplied cursor. Encoding failures and panics do not publish a commit; the post-commit callback runs before notification. Queue bytes and the cross-language wire format are unchanged. The public IPC and SDK contracts describe the updated interface.Measurements and limits
Selected local release measurements on macOS arm64, comparing each optimization with its own baseline:
Source submission removes one record-buffer allocation per record. Egress removes one payload-buffer allocation per nonempty output; copying into each destination queue remains necessary.
The filtered collection benchmark was about 58% faster. Complete localhost HTTP requests for filtered Runner-local metrics were about 39–40% faster with 256 Pipeline-id label combinations. Those HTTP measurements include the client and server but exclude Pipeline/Plugin communication.
This is not a claim of universal speedup:
Validation
The final code passed
tools/verify-rust.shon macOS arm64 with Rust 1.97.1, including formatting, checks, Clippy, workspace/SDK tests, real Rust and Java plugins, HTTP metrics, cross-language vectors, Loom and doctests.Focused coverage includes queue-full retries, encoder failure/panic/length mismatch, commit-before-notification behavior, writer termination during encoding, Lua integer and read-only behavior, and metrics output equivalence. Metrics tests compare complete Protobuf bytes from the same SDK snapshot and verify that empty filtered results still sample callbacks and preserve cumulative history. JSON and Prometheus HTTP samples were also parsed and checked.