Skip to content

Add an opt-in no_std Rust Runtime API client for Linux - #208

Draft
GradExMachina wants to merge 1 commit into
aws:nodejs24.xfrom
GradExMachina:experiment/rust-ric
Draft

GradExMachina wants to merge 1 commit into
aws:nodejs24.xfrom
GradExMachina:experiment/rust-ric

Conversation

@GradExMachina

Copy link
Copy Markdown

Hi team! I got curious about the cost of copying large invocation payloads, especially when durable functions replay checkpointed results. I built an opt-in #![no_std] Rust implementation of rapid-client.node to measure it. The JavaScript runtime and default C++ install are unchanged.

This is a draft for discussion. Would the memory savings justify maintaining another transport? I'd also be happy to use these benchmarks to investigate reducing copies in the existing client.

Scope

Linux OCI images. Set RIC_NATIVE_CLIENT=rust during installation to build the alternative client with Cargo. There are no changes to the managed runtime build.

  • Keep next() on Node's worker pool and keep buffered done() and error() synchronous.
  • Reuse connections and buffers, keep offsets into the receive buffer for metadata, and encode results into the outgoing buffer.
  • Replace the bundled libcurl 7.83.1 and AWS C++ runtime library in the optional build with httparse, Linux sockets and direct Node-API calls.

Local measurements

Linux ARM64, Node 26.13.1, Rust 1.100.1, AWS C++ library and binding built at -O3, bundled curl at -O2. Medians with alternating client order.

Workload C++ Rust
6 MiB buffered echo, each direction 27.7 ms 8.8 ms
Nine durable invocations, transport and JSON 109.2 ms 79.2 ms
Same workflow, active time including SDK and handler 991.0 ms 975.9 ms
Peak Node process memory replaying those events 144.8 MiB 106.5 MiB

Peak memory fell 26% in the replay test. The last event contained 5.5 MiB of checkpointed results. The memory test included JSON parsing and excluded the SDK and mock server. In the live SDK test, transport and JSON took 28% less time. Active time, excluding waits between invocations, fell about 1.5%.

These are warm loopback measurements with all durable state inline. They don't measure cold starts, paginated replay or production Lambda performance. See test/native/README.md for the method and reproduction commands.

Verification and review

The native and streaming checks are manual in this draft. Run npm run test:native and npm run test:stream after building the bundle and the Rust addon.

  • All 325 upstream tests passed. Two intermediate parallel runs hit timing failures in mocked concurrency tests. The serial rerun and final build passed.
  • Native contract and streaming checks passed on Node 22 and 26. Streaming stayed in JavaScript. The test verified early delivery, backpressure, an 8 MiB response, error trailers and recovery.
  • RIC 4.0.2 and 4.0.3 passed local emulator checks on Node 26. ARM64 was the only execution target. The Rust crate passed cargo check for x86-64.
  • Ran npm install and tested a local npm tarball. The lockfile was unchanged.

The optional build brings a second toolchain and custom HTTP/1.1 framing. The socket lifecycle, allocator and unsafe Node-API boundary need independent review. A panic or unrecoverable allocation failure aborts Node. I would keep this experimental.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant