Compare performance profiles

Use separate profiles for each transport mode:

  • plain TCP
  • TCP with low-memory allocator behavior
  • TCP with TLS
  • HTTP

Do not compare TLS and non-TLS runs as if they measure the same path. Likewise, do not compare two runs if the stress client version changed.

Recommended plain TCP baseline config:

examples/nacelle-stress-server/configs/tcp.toml

Then run:

./examples/run-stress-test.sh --config examples/nacelle-stress-server/configs/tcp.toml --connections 256 --pipeline 8 --duration-secs 30 --payload-bytes 256

Record the tested commit, kernel, CPU model/topology, CPU governor, Rust toolchain, allocator, features, configuration, connection count, pipeline depth, payload, TLS provider, and client revision with every result. A throughput number without that context is not a comparable baseline.

Also record the metrics recorder and switches, warm-up, sample duration, repetitions, and any uncommitted harness changes. Repeat the unchanged baseline before choosing regression thresholds, then compare each candidate both with its parent and the pinned starting revision. Keep allocation-instrumented runs separate from throughput/latency samples. Shared-host measurements establish local variance, not a dedicated-host performance guarantee.

For Linux stress-worker experiments, record the process CPU mask and any --worker-cpus list separately. Compare an unchanged default, affinity alone, and --worker-local-response under the same worker count and effective CPU placement. Worker-local templates can reduce shared reference-count traffic while increasing RSS; record peak memory and single-connection controls rather than assuming a multi-worker gain applies to them. Keep the response-write policy identical unless batching is the explicit variable under test. The default shared 64-byte fixture template is static; use a custom response size when isolating owned-template contention, and record --response-bytes.

Check serving future sizes

The compiler-pressure example reports unpolled future sizes for ordinary serving, owned-admission handoff, and surrounding runtime entry points. Serial handoff coverage includes the direct helper and a protocol with 6 KiB of inline connection state. Its regression test retains a 16 KiB ceiling for these representative types:

cargo run -p nacelle-examples --no-default-features --features bench,http,peer-limits,tcp,tls-self-signed --bin compiler-pressure
cargo test -p nacelle-examples --no-default-features --features bench,http,peer-limits,tcp,tls-self-signed --bin compiler-pressure -- --nocapture

Compare the same toolchain, target, feature set, compiler flags, and profile. Start with the unoptimized dev/test builds used during development and Clippy; repeat without peer-limits for the default-off configuration. These sizes describe concrete future storage, not peak thread-stack use, heap allocation counts, or throughput. A downstream protocol or handler can require a different amount of inline state.

Two distinct TCP workloads

Build both stress tools before measuring. For one persistent connection with one request outstanding, use immediate responses, one listener, and one client worker. On Linux, pin the process to an allowed physical-core CPU; one unpinned listener shares the main thread's current-thread runtime:

taskset -c 0 target/release/nacelle-stress-server \
  --config examples/nacelle-stress-server/configs/tcp.toml \
  --bind 127.0.0.1:7879 --server-threads 1 \
  --handler-mode serial --response-write-mode immediate

In another terminal:

TOKIO_WORKER_THREADS=1 taskset -c 12 target/release/nacelle-stress-test \
  --addr 127.0.0.1:7879 --connections 1 --pipeline 1 \
  --duration-secs 30 --payload-bytes 256

Replace 0 and 12 with allowed CPUs on separate physical cores. Serial dispatch avoids per-request shared connection-context cloning; the fixture's plaintext path also avoids generic split locking. Compare serial and shared dispatch separately, then hold the selected mode and runtime topology fixed between revisions. This is not connection churn: do not set --requests-per-connection 1. For a separate client-runtime comparison, add --current-thread to the client command above while keeping the server binary and configuration fixed. This removes the extra client worker thread; it is an end-to-end profile comparison, not evidence of a server implementation improvement. Hold the client runtime fixed when comparing server revisions. An explicit --worker-cpus 0 instead adds a dedicated listener runtime and thread, leaving supervision on the main thread. Measure that topology separately rather than assuming it improves a one-request workload.

For the serial fixture's native I/O path, select --handler-mode serial with --response-write-mode coalesce-buffered and use multiple requests in flight. Measure a one-connection, pipeline-64 case separately from a many-connection, pipeline-8 case. Keep listener count, affinity, handler mode, and the same coalesced policy fixed at both revisions. A gain from switching immediate delivery to coalescing is a configuration gain, not evidence that the one-request path improved. Report server CPU per completed request and latency; coalescing cannot combine responses that the client has not requested yet.

Sequential TCP and TLS round trips

Use one persistent connection, pipeline depth 1, and immediate responses when measuring a sequential driver. Receive and validate the complete response before sending the next request. Do not substitute a pipelined or batched workload. Keep the request payload at 256 bytes and the response behavior identical in plaintext and TLS comparisons.

For local self-signed TLS, use the same one-listener server command above with examples/nacelle-stress-server/configs/tcp-tls.toml. Run the client with:

taskset -c 12 target/release/nacelle-stress-test \
  --addr 127.0.0.1:7879 --connections 1 --pipeline 1 \
  --payload-bytes 256 --current-thread --tls-insecure \
  --warmup-secs 5 --duration-secs 30

The insecure trust option is only for this local self-signed fixture. Record the printed negotiated TLS version and cipher. Omit --tls-insecure and select the plaintext server config for the transport control; do not silently change response size, timeouts, metrics, or allocator.

Warmup uses the same established connections and drains their responses before the measured phase. measurement_start and measurement_end are flushed outside the request loop. Initial connections, TLS handshakes, warmup, and final shutdown are excluded from the client request statistics. Server console windows still include warmup: use matching steady-state CPU snapshots or whole diagnostic windows after warmup rather than dividing startup totals by measured requests.

Report RPS, mean RTT, p50/p95/p99, client and server user/kernel CPU per request, memory, thread count, and allocation/syscall evidence separately. Current RTT starts before request frame preparation and includes write/flush through complete response validation. Earlier client revisions started timing after the write; their latency values are not comparable. Current percentiles include every completion in a bounded histogram, whose bucket upper bounds overestimate by less than 0.4%. Repeat unchanged controls and interleave baseline/candidate runs before claiming a gain.

For a separate blocking-client experiment, add --blocking-io while keeping the same binary, server, TLS cipher, payload, and pipeline depth 1. It creates one additional blocking worker per connection; compare memory and thread count as well as latency and CPU. It changes client I/O scheduling, not the server implementation, and does not allow requests to overlap within a connection.

After the one-connection comparison, measure 2, 4, 8, 16, and 32 independent connections with --pipeline 1. Record worker counts and CPU placement for each case. Report aggregate throughput separately from single-connection throughput; connections / RPS is not an independently measured latency distribution.

To compare the opt-in compact response-buffer profile, keep the builds separate:

cargo build --release -p nacelle-stress-server --target-dir target/perf-baseline
cargo build --release -p nacelle-stress-server --features nacelle/compact-connections --target-dir target/perf-compact

Run target/perf-baseline/release/nacelle-stress-server and target/perf-compact/release/nacelle-stress-server with otherwise identical commands and immediate responses. Keep coalescing as a separate control; it retains its configured buffer capacity in both builds. For idle-memory comparisons, complete and validate at least one response on every connection before sampling settled RSS. Report the verified socket count, startup RSS, incremental RSS per connection, allocator, and response-buffer capacity. Stay below the configured connection cap and within idle deadlines. Process RSS excludes kernel socket memory and does not establish a deployment's maximum connection capacity.

Suggested local benchmark:

cargo bench -p nacelle-examples --features "bench tcp"

For the codec/TCP integration specifically, run both Criterion targets:

cargo bench -p nacelle-codec --bench framed_comparison --all-features
cargo bench -p nacelle-examples --bench critical_paths --features "bench tcp"

The same critical-path target has opt-in HTTP/1 loopback cases:

cargo bench -p nacelle-examples --bench critical_paths --features "bench tcp http" -- http_connection_round_trip --noplot

http_connection_round_trip/buffered_echo/0 and http_connection_round_trip/buffered_echo/65536 measure one complete connection, request, and chunked response. They use two Tokio workers, the system allocator, default Nacelle telemetry switches without a recorder, and an application that buffers the request before echoing it. Client connection, allocation, and read costs are included. These are not persistent keep-alive, slow-reader, p99, or HTTPS measurements. The comparison scripts' critical-paths suite uses the TCP-only feature selection; run this HTTP selection separately with an identical harness at both revisions.

For persistent HTTP/1 requests without pipelining:

cargo bench -p nacelle-examples --bench critical_paths --features "bench tcp http" -- http_keep_alive --noplot

These cases use 1 or 16 concurrent connections, 64 sequential requests per connection, and empty or 256-byte echoed bodies. They use the same two-worker runtime, system allocator, and no-recorder telemetry as the connection benchmark. Connection setup is included once per 64 requests. Client work is included; these cases do not measure server-only CPU, p99 latency, or HTTPS.

Compare shared permit contention separately:

cargo bench -p nacelle-examples --bench critical_paths --features "bench tcp" -- request_permit_contended --noplot

The owned and borrowed cases enforce the same runtime request limit. Borrowed permits are used internally by scoped transport operations; they do not disable accounting or replace public owned permits.

To isolate fragmented buffered bodies:

cargo bench -p nacelle-examples --bench critical_paths --features "bench tcp" -- tcp_body_read_128x256 --noplot

Each case processes 128 requests with 256-byte bodies over in-memory I/O capped at 32 or 4,096 bytes per read. The former forces the incomplete-body fallback; the latter is a buffered control. The fixture checks each complete body, uses a current-thread runtime, and installs no recorder. These are body-path timings, not a measurement of fragmentation frequency or network throughput. Fewer body allocations alone do not establish lower CPU cost.

The ready_timeout group in the same target isolates timeout-wrapper cost for an immediately-ready future, comparing Tokio's wrapper with Nacelle's deferred timer construction. It does not measure pending timers or network latency.

The telemetry group can be run independently:

cargo bench -p nacelle-examples --bench critical_paths --features "bench tcp" -- telemetry --noplot

The TCP crate also measures one complete connection plus one request through the metrics facade, separating disabled metrics, default switches, request timing, and TCP phase timing. All four cases use an in-memory duplex transport without a metrics recorder; the feature selection below does not make them TLS handshakes:

cargo bench -p nacelle-tcp --bench telemetry_paths --features "buffer-rotation phase-timing rustls tls-self-signed" -- --noplot

Response delivery policies have a separate end-to-end benchmark:

cargo bench -p nacelle-tcp --bench response_delivery -- --noplot

Measure optional application-admission overhead separately:

cargo bench -p nacelle-examples --bench admission --features "bench tcp http" -- --noplot

The TCP cases use four in-memory connections with 64 pipelined 32-byte requests each, comparing default and H=24/B=4096 bounded reads, ready allowance, and capacity-four/capacity-one semaphores under immediate and coalesced delivery. Handlers yield once in every case to exercise queued admission. HTTP uses four loopback connections per iteration, empty or 64 KiB requests, and empty or four-chunk responses. Both use default telemetry without a recorder. TCP uses one current-thread runtime; HTTP uses two Tokio workers. These are enabled-policy cost profiles, not substitutes for unchanged-harness parent/default comparisons, allocation measurements, or tail-latency and memory workloads.

Compare a tag or commit

The PowerShell comparison scripts keep data under target/performance-comparisons, resolve tags to immutable commit hashes, and use detached temporary worktrees so the current checkout is not modified. Each revision receives an isolated Cargo target directory; only Criterion baseline data is copied into the candidate target before comparison, preventing build artifacts from being reused across worktrees.

Capture all Criterion suites for the current commit, a release tag, or another commit:

./scripts/capture-performance-baseline.ps1
./scripts/capture-performance-baseline.ps1 -Reference v0.3.0
./scripts/capture-performance-baseline.ps1 -Reference 00747f3

With no parameters, HEAD is captured in a detached worktree. Uncommitted working-tree changes are intentionally excluded from that baseline.

Compare the current working tree with a captured baseline:

./scripts/compare-performance.ps1 -BaselineReference v0.3.0

Compare two committed revisions without checking either one out:

./scripts/compare-performance.ps1 `
	-BaselineReference v0.3.0 `
	-CandidateReference 0123456789abcdef

Use -Suite to limit both capture and comparison to one or more matching suites: codec, critical-paths, telemetry, or response-delivery. For example:

./scripts/capture-performance-baseline.ps1 `
	-Reference v0.3.0 `
	-Suite critical-paths,telemetry
./scripts/compare-performance.ps1 `
	-BaselineReference v0.3.0 `
	-Suite critical-paths,telemetry

The default capture runs every suite available at the selected commit. The critical-paths suite follows its historical move from nacelle to nacelle-examples. The telemetry and response-delivery suites are omitted for commits that predate those benchmark targets. When comparison omits -Suite, it uses exactly the suites recorded by the baseline, so newer-only targets do not invalidate an older baseline. Within a shared suite, Criterion compares matching benchmark IDs and measures newer IDs without a delta when no baseline exists for them.

The scripts use explicit feature selections and do not restore removed features for historical revisions. A historical suite that requires a removed feature will fail to build; select a compatible revision or a different suite instead.

Each capture records the resolved commit, Rust toolchain, operating system, architecture, CPU information, selected suites, and full benchmark log. Each comparison records the same candidate metadata and Criterion's percentage and confidence-interval output. Use -Force to replace an existing baseline for the same resolved commit.

Run native host workloads

On a dedicated Linux host, the native workload harness detects physical cores, SMT siblings, sockets, NUMA nodes, memory, and CPU governors. It reserves one physical core per NUMA node for the operating system and uses one logical CPU per remaining physical core. Review the generated plan without building or running workloads:

./scripts/run-native-performance.ps1 -PlanOnly

Run the default capacity matrix with a warm-up before every measured sample:

./scripts/run-native-performance.ps1 `
	-Runs 3 `
	-WarmupSecs 15 `
	-DurationSecs 30

The harness defaults to three 30-second measured runs per workload. The default capacity matrix uses 50 persistent connections, pipeline depth 1, worker counts of 1, 2, 4, 8, 16, 32, and 36, and response bodies of 0, 1, 10, and 100 KiB. Worker counts larger than the isolated server core set detected on the host are omitted. Requests use a zero-byte body while retaining the protocol's fixed frame overhead; sample banners report request and response body sizes separately.

Run plain TCP and TLS as separate result sets:

./scripts/run-native-performance.ps1 `
	-Config examples/nacelle-stress-server/configs/tcp.toml `
	-OutputDirectory target/native-performance/plain
./scripts/run-native-performance.ps1 `
	-Config examples/nacelle-stress-server/configs/tcp-tls.toml `
	-OutputDirectory target/native-performance/tls

The earlier diagnostic profiles remain available explicitly. For example:

./scripts/run-native-performance.ps1 -Profile min-rtt,pooled

Use -Profile all to run both the capacity matrix and the diagnostic minimum-RTT, pooled, pool-saturation, and pipelined-throughput profiles. Override the capacity dimensions with -CapacityWorkerCounts or -CapacityResponseKiB.

The harness builds native release binaries once, starts a fresh server for each sample, applies process and memory binding with numactl, and writes the host snapshot, exact workload plan, raw server/client logs, per-run parsed results, and median summary JSON under target/native-performance. It warns when it detects virtualization or a non-performance CPU governor and refuses to reuse an occupied bind address. Use -SkipBuild only when the release binaries already match the current source.

The codec target measures length-delimited encoding, compares direct decoding with MessageReader::decode_buffered, measures incomplete-header calls, and separates the no-op buffer-rotation check from replacing an empty 256 KiB buffer. The TCP target measures per-connection decoder construction and compares direct reference-protocol decoding with the buffered 64-request head/body drain used by the connection loop. Treat the rotation replacement result as allocation cost, not per-request overhead.

The runtime_limits benchmark group covers connection/request permit acquire/drop overhead. Watch it closely after changes to NacelleRuntimeState.

connection_permit_contended/{bounded,unlimited} adds four persistent worker threads sharing one state. Each timed round includes start/finish barriers and 1,024 acquire/drop operations; thread creation is outside the measurement. Treat it as a contention comparison, not isolated single-permit latency. Keep CPU affinity, worker count, metrics configuration, and the same benchmark harness fixed on both revisions. The peer_rate_limit_distinct_peers group measures the rate table directly, separately from runtime-state admission. It and the per-peer runtime-limit cases require --features "bench tcp peer-limits". Keep that feature selection identical for both revisions.

Profile Linux CPU and allocations

Use the Linux profiling helper for repeatable plain-TCP diagnostics:

./scripts/profile-linux.sh --tool baseline
./scripts/profile-linux.sh --tool perf
./scripts/profile-linux.sh --tool heaptrack

The helper builds the profiling Cargo profile with optimization, debug information, and frame pointers. Its default --feature-set minimal uses --no-default-features, which disables TLS and the server's mimalloc feature. The stress client still uses mimalloc. The stress server's console recorder remains active, but the helper keeps body-size recording off by default for comparability with earlier profiles. Pass --request-metrics counters-and-bytes to include the server's default byte accounting. Its current console recorder stores bounded sharded byte totals, not raw byte-size samples; compare the same recorder revision, shard policy, and switches when attributing overhead. Shard selection occurs when cached handles register; aggregation occurs during console snapshots. The system allocator is required because Heaptrack cannot intercept calls made directly to mimalloc. Treat this as a diagnostic profile, not as a matched comparison with the default mimalloc build.

Use --feature-set default to profile the default mimalloc and Rustls-capable binaries. Self-signed Rustls workloads also require a TLS config and the explicit local-test trust flag:

./scripts/profile-linux.sh \
	--tool perf \
	--feature-set default \
	--config examples/nacelle-stress-server/configs/tcp-tls.toml \
	--tls-insecure

For a return-to-idle profile, keep the default mimalloc build and enable its immediate page-purge configuration:

./scripts/profile-linux.sh \
	--tool baseline \
	--feature-set default \
	--low-memory

The profile metadata records low_memory=true. This mode is rejected with --feature-set minimal because that diagnostic build uses the system allocator.

The helper rejects Heaptrack with the default feature set because direct mimalloc calls are invisible to Heaptrack. It also rejects --tls-insecure with the minimal feature set because that client omits Rustls.

Pass disjoint CPU lists after reviewing the native harness plan:

pwsh -NoProfile -File ./scripts/run-native-performance.ps1 -PlanOnly
./scripts/profile-linux.sh \
	--tool perf \
	--server-cpus 2,4,6,8,10,12,14,16 \
	--client-cpus 3,5,7,9,11,13,15,17,19,21,23

For user-space profiling of processes owned by the current user, Linux must permit performance counters. A value of 2 keeps kernel profiling disabled:

sudo sysctl -w kernel.perf_event_paranoid=2

Each run writes metadata, raw logs, and text reports under target/linux-profiles. The perf mode warms the server before attaching and records cycles:u at 999 Hz with frame-pointer call graphs. Heaptrack launches the server directly so allocator interception survives process startup, then applies any requested CPU affinity to all server threads.

Client logs also include server user/kernel CPU seconds and server_cpu_us_per_request, computed from process-wide /proc/PID/stat counters around each client invocation. CPU totals include connection setup, teardown, and the server's metrics-console work during that interval; they exclude client CPU. The counters have clock-tick granularity, so use several-second samples. server_average_cores divides that CPU total by the client's reported load duration and is approximate because client startup lies outside that duration.

Start a non-pipelined comparison with the same explicit profile at both revisions:

./scripts/profile-linux.sh \
	--tool baseline \
	--config examples/nacelle-stress-server/configs/tcp.toml \
	--server-threads 4 --connections 64 --pipeline 1 \
	--payload-bytes 256 --warmup-secs 5 --duration-secs 15 --runs 3

Add disjoint physical CPU lists for the host, keep the client binary fixed, and alternate baseline/candidate order. Compare CPU per request, user/kernel split, throughput, and tail latency together. Repeat with pipeline depth 8 as a separate control. Do not treat a small throughput difference inside baseline variance as an improvement, or extrapolate a user-space microbenchmark to total socket CPU.

The helper can compare handler ownership and response delivery without changing their safe defaults:

./scripts/profile-linux.sh --tool perf --handler-mode serial
./scripts/profile-linux.sh \
	--tool baseline \
	--response-write-mode coalesce-buffered \
	--pipeline 8 \
	--runs 3

July 2026 Linux response-delivery diagnostic

The following results are local confidence checks from an Intel Xeon Silver 4214 host with 24 physical cores, Linux 6.8, and Rust 1.95.0. The profiling build used the system allocator, no TLS, and the former metrics configuration, eight pinned server workers, 256 persistent connections, 256-byte request bodies, 64-byte response bodies, and all timeout defaults enabled. Server and client CPU sets were disjoint. Each matrix cell used a five-second warm-up and three measured ten-second runs; pipeline depths 1 and 8 also received ABBA interleaved checks.

PipelineImmediate medianCoalesced medianLocal delta
1614,661 req/s624,258 req/sinconclusive; ABBA was -1.0%
8763,646 req/s1,081,277 req/s+41.6%
32724,094 req/s1,256,126 req/s+73.5%

All clients completed without reported failures. The pipeline-8 ABBA check measured 764,854-774,894 req/s for immediate delivery and 1,072,662-1,075,516 req/s for coalesced delivery. Matched perf captures lost no samples; coalescing reduced write_all_tracked_with_timeout self share from 4.33% to 1.39%, ResponseDelivery::write_pending from 4.14% to 1.68%, and TCP write polling from 1.59% to 0.46%. The connection loop always flushes after it drains the requests already decoded from the current read buffer and before it awaits another socket read.

These loopback saturation results support coalescing as an explicit option for highly pipelined workloads, not as a universal default. Pipeline-1 performance showed no repeatable benefit, and target-network latency, response sizes, backpressure, TLS, and telemetry require separate measurements.

Default-feature plain TCP and Rustls diagnostic

A follow-up on the same host used the then-default stress-server feature set: mimalloc, the former OpenTelemetry recorder with byte metrics, and self-signed Rustls support. The workload, CPU sets, timeout defaults, warm-up, sample duration, and three-run cell size matched the preceding matrix. Plain TCP and Rustls were measured as separate transport profiles.

TransportPipelineImmediate medianCoalesced medianLocal delta
Plain TCP1537,566 req/s536,274 req/s-0.2%
Plain TCP8619,749 req/s1,168,411 req/s+88.5%
Plain TCP32608,519 req/s1,329,735 req/s+118.5%
Rustls1478,062 req/s471,512 req/s-1.4%
Rustls8524,887 req/s529,998 req/s+1.0%
Rustls32547,103 req/s546,342 req/s-0.1%

All 36 measured client runs completed without reported failures; all cells had at most 1.1% min-to-max spread. At pipeline depth 8, matched perf captures lost no samples. Plain coalescing reduced tracked write-loop self share from 2.10% to 0.47%, pending-write self share from 1.78% to 0.42%, send from 0.62% to 0.12%, and TCP write polling from 0.53% to 0.09%. The equivalent Rustls pair was throughput-neutral: tracked write-loop self share remained approximately 1.01%, while encryption, TLS buffering, and the former metrics aggregation remained material costs.

Deep-pipeline Rustls testing also exposed two stress-path correctness gaps. The client now flushes buffered TLS requests before reading responses, and the TCP connection driver flushes the underlying transport before another request read and performs a shutdown-timeout-bounded shutdown. This delivers terminal TLS records promptly and emits close_notify. Final pipeline-32 Rustls samples all completed in approximately 10.02 seconds instead of waiting for the 30-second read timeout.

These results support coalescing for measured plain-TCP pipelined workloads on this host. They do not support enabling it for Rustls or pipeline-1 workloads.

Historical disabled-policy specialization

A matched local comparison used the telemetry_paths benchmark at checkpoint 0bce7f0 and after caching the effective TCP telemetry plan once per connection. Both builds used the same WSL2 host/toolchain and all TCP features:

PathBeforeAfterLocal delta
Metrics disabled5.72-5.76 us5.03-5.07 usapproximately 12% lower
Metrics enabled7.00-7.04 us7.02-7.08 usno material change

The optimized path did not construct NacelleMetricsContext or metric attribute arrays when metrics are disabled, and request/phase mode checks are cached in a copyable per-connection plan. Connection/request permits remain active because they enforce runtime limits and expose operational state. Disabling telemetry does not disable those safety policies.

On the same local WSL2 host, 64 already-buffered one-byte requests producing 32-byte responses measured. The first two rows use a 2 KiB base response buffer; the threshold rows use a 1 KiB base buffer:

PolicyTimeRecorded writes
Immediate27.14-27.55 us64
CoalesceBuffered20.18-20.40 us1
FlushAtBytes(1024)20.22-20.45 us2
FlushAtBytes(2048), grows from 102420.40-20.63 us1

This is a synthetic in-memory writer benchmark and demonstrates dispatch/write amortization plus one transactional buffer-growth case, not network throughput. Keep immediate delivery for latency-first workloads unless a matched workload shows a benefit.

Response coalescing depth and persistent-pool controls

The response_delivery benchmark also provides two policy-matched workload families at pipeline depths 1, 8, and 32:

  • same_socket: one persistent in-memory connection and one request window
  • pool: eight persistent in-memory connections, each processing eight request windows; the next window becomes readable only after the previous response window is delivered

Both families compare Immediate with CoalesceBuffered on the same server, decoder, handler, response shape, runtime, and transport. Every response is 32 bytes. The benchmark asserts total write count and largest write size on every iteration. Response-buffer capacity is 2 KiB, so these cases remain inside the base connection allocation and do not exercise overflow growth.

Run them with:

cargo bench -p nacelle-tcp --bench response_delivery --features "buffer-rotation phase-timing rustls tls-self-signed"

A local confidence run based on commit 9be59a0 with a modified worktree used Rust 1.95.0 on Linux 6.6.87.2 WSL2 and an Intel Xeon Platinum 8370C virtualized topology (one socket, eight visible cores, two threads per core). Times are Criterion 95% confidence intervals from that one host.

Same-socket depthPolicyTimeWritesLargest batchMedian delta
1Immediate5.569-5.699 us132 Bbaseline
1CoalesceBuffered5.536-5.641 us132 B1.1% lower
8Immediate8.497-8.577 us832 Bbaseline
8CoalesceBuffered7.593-7.758 us1256 B10.2% lower
32Immediate17.834-17.944 us3232 Bbaseline
32CoalesceBuffered14.344-14.436 us11,024 B19.6% lower
Pool depthPolicyTimeTotal writesLargest batchMedian delta
1Immediate51.695-52.949 us6432 Bbaseline
1CoalesceBuffered50.578-50.891 us6432 B2.8% lower
8Immediate229.82-230.90 us51232 Bbaseline
8CoalesceBuffered176.78-177.72 us64256 B23.1% lower
32Immediate837.09-851.92 us2,04832 Bbaseline
32CoalesceBuffered608.71-614.00 us641,024 B27.6% lower

Depth 1 remains the latency control: both policies perform one write per window, and their intervals are close. At depths 8 and 32, coalescing reduces one response window to one write and lowers elapsed time in this synthetic adapter workload. These results demonstrate write-path amortization, not socket syscall cost, network throughput, allocator counts, or production latency.

Suggested RPS comparison:

./examples/run-stress-test.sh --config examples/nacelle-stress-server/configs/tcp.toml --server-threads 48 --connections 256 --pipeline 8 --duration-secs 30 --payload-bytes 256

The stress server installs a console recorder backed by metrics-util and prints a compact metrics snapshot every 5 seconds. Request metrics use the generic telemetry request_metrics mode; counters-and-bytes is the default, counters omits body-size writes, and off suppresses both request counters and byte histograms. Diagnostics remain opt-in, which avoids request Instant work on core/HTTP paths unless duration metrics or HTTP access logs are enabled. Use --request-metrics counters when comparing the cost of byte accounting. Use the telemetry_paths Criterion target for a no-recorder facade baseline; every stress-server feature set installs the console recorder.

The checked-in root config.toml enables self-signed TCP TLS for local stress runs. For the plain TCP throughput baseline, use examples/nacelle-stress-server/configs/tcp.toml. Compare TLS and non-TLS runs separately:

./examples/run-stress-test.sh --config examples/nacelle-stress-server/configs/tcp.toml
./examples/run-stress-test.sh --config examples/nacelle-stress-server/configs/tcp-tls.toml

The examples/run-stress-test.sh and examples/run-stress-test.ps1 helpers apply root config.toml first, then the selected profile, and choose the matching client mode automatically.

Guardrails:

  • keep shutdown task tracking at the connection/listener boundary
  • avoid per-request locks in the TCP hot path
  • keep telemetry observers optional; the default NoopObserver must remain allocation-free
  • preserve single-chunk body fast paths
  • tune TCP buffer sizes for the connection count instead of relying on large defaults