libatbus-go Benchmark
This page measures only the Go communication library libatbus-go (full v2 protocol stack). It does not represent end-to-end application RPC performance in atsf4g-go services.
Real business RPCs built on atsf4g-go add layers above libatbus-go:
- Dispatch and concurrency control:
libatapp-goworker-pool dispatch,Dispatcherunpacking, andActorExecutortoken queuing and handoff (see Go Framework (In Progress)); - Richer RPC headers and routing: business RPC framing, router object lookup and forwarding, service discovery, and multi-hop
atproxyforwarding; - Observability and storage: logging, telemetry, domain logic, and Redis or external I/O.
Therefore, actual business RPC throughput and QPS will be lower than these communication-library baselines. Use this report to evaluate Go transport ceilings, cipher and compression costs, GOGC / GOMEMLIMIT tuning, memory breakdown, same-host transport gains, and order-of-magnitude differences against C++ libatbus (see libatbus Benchmark).
Background
libatbus-go is the Go implementation of the atframework inter-server communication bus, aligned with the C++ libatbus v2 protocol stack (framing, Protobuf, handshake, X25519 key exchange, encryption, and compression). Measurements were collected on the same dedicated Linux host used for the C++ libatbus benchmark plus a Windows workstation, reusing the same payload generator and aggregation rules across cross-platform TCP baselines, single-core pinned runs (GOMAXPROCS=1), GOGC=800 comparisons, Unix domain sockets, 2-to-1000-node fan-in, and high-connection receiver and zstd sender memory diagnostics.
Full reproduction commands and all expanded tables live in atframework/libatbus-go/docs/Benchmark.md inside atsf4g-go and in the GitHub benchmark report.
Key Results
The table below summarizes unencrypted, uncompressed ceilings (1 KB = 1024 B, 1 MB = 1024 KB, 1 GB = 1024 MB) alongside same-host C++ libatbus numbers:
| Scenario | Channel / Mode | 200 B (QPS / Throughput) | 1 KB (QPS / Throughput) | 8 KB (QPS / Throughput) | 64 KB (QPS / Throughput) | 300 KB (QPS / Throughput) |
|---|---|---|---|---|---|---|
| Linux (single pair) | TCP, default | 919.2K / 175.3 MB/s | 597.4K / 583.4 MB/s | 207.0K / 1.58 GB/s | 30.0K / 1.83 GB/s | 6.7K / 1.91 GB/s |
| Linux (single pair, pinned) | TCP, GOMAXPROCS=1 each | 897.4K / 171.2 MB/s | 551.9K / 538.9 MB/s | 150.4K / 1.15 GB/s | 27.2K / 1.66 GB/s | 6.4K / 1.83 GB/s |
Linux (single pair, GOGC=800) | TCP | 992.7K / 189.3 MB/s | 651.8K / 636.5 MB/s | 212.1K / 1.62 GB/s | 33.8K / 2.07 GB/s | 7.8K / 2.24 GB/s |
| Linux (single pair) | unix:// | 966.2K / 184.3 MB/s | 612.8K / 598.4 MB/s | 211.3K / 1.61 GB/s | 30.7K / 1.87 GB/s | 7.4K / 2.12 GB/s |
| Windows (single pair) | TCP, default | 911.6K / 173.9 MB/s | 541.2K / 528.6 MB/s | 77.2K / 602.8 MB/s | 13.2K / 823.8 MB/s | 1.4K / 401.0 MB/s |
| Linux (10-node fan-in) | TCP, CPU-pinned | 1.41M / 268.5 MB/s | 1.10M / 1.05 GB/s | 349.4K / 2.67 GB/s | 94.1K / 2.87 GB/s (32 KB) | 10.3K / 2.95 GB/s |
| Linux (1000-node fan-in) | TCP, CPU-pinned | 1.14M / 217.9 MB/s | 888.6K / 867.8 MB/s | 223.7K / 1.71 GB/s | 65.7K / 2.00 GB/s (32 KB) | 8.5K / 2.43 GB/s |
| C++ Linux (single pair, same host) | TCP, mimalloc | 3.66M / 697.5 MB/s | 1.65M / 1.58 GB/s | 302.0K / 2.30 GB/s | 42.7K / 2.60 GB/s | 9.6K / 2.76 GB/s |
| C++ Linux (1000 nodes, same host) | TCP, mimalloc | 3.70M / 706.6 MB/s | 1.39M / 1.33 GB/s | 243.6K / 1.86 GB/s | 73.2K / 2.23 GB/s (32 KB) | 9.4K / 2.70 GB/s |
Each C++ side saturates one core, whereas the default, GOGC=800, and multi-node Go rows use multiple cores. Compare strictly single-core numbers via the pinned row and the CPU-normalized breakdown below.
Recommended deployment settings:
| Deployment scenario | Recommended channel & algorithms | Runtime & notes |
|---|---|---|
| Linux cross-host intranet (high throughput) | TCP + AES-128-GCM or AES-256-GCM, no compression | Raise GOGC to 400–800 (or pair with GOMEMLIMIT) on throughput-critical nodes; AES-GCM costs 25%–39%, and tuning GOGC recovers 12%–26% on large payloads |
| Bandwidth-constrained WAN | TCP + snappy or lz4 with AES-GCM | snappy is ~20% faster than lz4 with a slightly better ratio; do not enable zstd or zlib until per-message encoder allocation is fixed (each zstd sender holds ~24 MB private RAM, requiring GOMEMLIMIT at high sender counts) |
| Linux same-host IPC | TCP or unix://, encrypt as needed | Go does not implement shm://; unix:// gains only 2%–5% over TCP, so choose by deployment convenience |
| Central fan-in receiver (~1000 senders) | TCP + AES-128-GCM, no compression or snappy | Dedicate 3–4 CPU cores to the receiver and pin senders (GOMAXPROCS=1) to remaining cores; set receiver GOMEMLIMIT above the live heap (~700 MB at 1000 nodes / 300 KB, e.g. 1GiB) to avoid 1.3 GB RSS without causing GC thrashing below live heap; keep default GOGC on large sender fleets |
| Disallowed in production | Disable raw ChaCha20 | Provides no authentication tag. In the Linux benchmarks without compression, throughput was 47%–84% lower than plaintext and 20%–69% lower than ChaCha20-Poly1305 |
Test Environment and Method
Runs used libatbus-go 7376c60 with node-layer performance optimizations, built standalone (GOWORK=off) with Go 1.27.4 and static linking (CGO_ENABLED=0):
| Item | Dedicated Linux Host (same as C++ report) | Native Windows |
|---|---|---|
| Runtime | Proxmox LXC container, Debian 13.7, 24 GB RAM (no swap) | Windows 11 Pro (build 26300), 125.1 GB RAM, active desktop |
| CPU | AMD Ryzen 9 9950X host, 12 online logical CPUs (0–11) | AMD Ryzen 9 9950X3D, 32 logical CPUs |
| Toolchain & build | go1.27.4 (GOOS=linux GOARCH=amd64 CGO_ENABLED=0 -trimpath) | go1.27.4 native build |
| Default runtime | GOGC=100, GOMAXPROCS=12 (except GC, single-core, and memory-diagnostic groups) | GOGC=100, GOMAXPROCS=32 |
| Key dependencies | protobuf v1.36.11, x/crypto v0.47.0, klauspost/compress v1.17.10, pierrec/lz4 v4.1.22, golang/snappy v0.0.4 | Same |
Test matrix and measurement rules:
- Matrix: single-pair TCP covers 22 cipher/compression combinations × 5 payload sizes (110 runs each on Linux and Windows, 15 s per run); same-host IPC tests
unix://(5 plaintext runs);GOGC=800(30 runs) replaces the C++ allocator comparison; single-core pinned (GOMAXPROCS=1per side, 30 runs) mirrors C++'s single-threaded loop; multi-node fan-in covers 2 / 10 / 100 / 1000 nodes × 20 combinations × 6 payload sizes (480 runs, 467 valid, 10 s per run); additional 30–90 s Linux memory-diagnostic and heap-profiling runs inspect receiver memory (1000 nodes, 2 nodes, and 3 connect/disconnect cycles) andzstdsender memory (300 / 600 / 1000 nodes vs plaintext andzlib, unarchived). - Flow control and payloads: single-pair runs use real ctrl + data dual connections. Because
libatbus-golimits its send queue by frame count (1024), the harness derives an in-flight message cap from the byte budget so 300 KB backpressure matches C++. Payloads use the same fixed-seed JSON-like text generator as C++; encrypted sessions use X25519 + HKDF-SHA256 with the default 3-hour key refresh (no renegotiation during runs). - Metrics and variance: QPS and payload throughput count raw application bytes delivered at the receiver, excluding the first 2 s warmup and trailing samples after the first connection closes, aggregated by duration-weighted median. Process CPU (100% = 1 core; Go processes can exceed 100%), GC CPU share (
/cpu/classes/gc/total:cpu-seconds), and peak RSS are also recorded. Differences within 10% on Linux (20% for GC-heavyzstd/zlib, with ~10% run-to-runzstdvariance) or 25% on Windows desktop are treated as noise.
Cross-Platform Baseline and C++ Comparison
Cross-Platform TCP Baseline and Single-Core Comparison
Unencrypted, uncompressed IPv4 TCP loopback. Top: QPS on a logarithmic scale; bottom: payload throughput on a linear scale.
Under default Linux settings, libatbus-go reaches 919.2K msg/s (175.3 MB/s) at 200 B and 1.91 GB/s (6.7K msg/s) at 300 KB. At <= 1 KB, sender CPU dominates (framing, checksum, queueing); from 8 KB upward, receiver CPU dominates (reads, checksum, decoding, and GC). Windows matches Linux within 10% on small packets (911.6K vs 919.2K at 200 B) but falls to 21%–44% of Linux from 8 KB onward (receiver GC CPU reaches 89% at 64 KB vs 48% on Linux; root cause unconfirmed).
Same-host Linux comparison between libatbus-go (default multi-core, single-core pinned, and normalized by the busier side's CPU) and single-core C++ libatbus (mimalloc):
| Payload | C++ 1-core QPS / Throughput | Go default QPS / Throughput (recv / send CPU) | Default Go / C++ | Pinned 1-core Go QPS (Go / C++) | Busier-side 1-core normalized Go / C++ |
|---|---|---|---|---|---|
| 200 B | 3.66M / 697.5 MB/s | 919.2K / 175.3 MB/s (103% / 131%) | 25% | 897.4K (25%) | 19% |
| 1 KB | 1.65M / 1.58 GB/s | 597.4K / 583.4 MB/s (112% / 159%) | 36% | 551.9K (33%) | 23% |
| 8 KB | 302.0K / 2.30 GB/s | 207.0K / 1.58 GB/s (196% / 160%) | 69% | 150.4K (50%) | 35% |
| 64 KB | 42.7K / 2.60 GB/s | 30.0K / 1.83 GB/s (194% / 123%) | 70% | 27.2K (64%) | 36% |
| 300 KB | 9.6K / 2.76 GB/s | 6.7K / 1.91 GB/s (166% / 148%) | 69% | 6.4K (66%) | 42% |
- Single-core pinned runs nearly match default multi-core throughput: 200 B differs by 2.4% (897.4K vs 919.2K), 1 KB by 7.6%, and
>= 64 KBby under 10% (only 8 KB drops 27% when the receiver is limited to one core). Extra cores used under default settings mostly absorb background GC and I/O goroutines rather than scaling throughput linearly. - The Go-to-C++ gap narrows as payload grows: single-core Go reaches 25%–33% of C++ on small packets and 50%–66% on large packets. On small messages, fixed per-message costs (Protobuf encoding, two full copies, goroutine channel handoff, and GC) dominate; on large messages, those fixed costs amortize and extra buffer copies become the main difference. With
AES-128-GCM, single-core Go reaches 39%–59% of C++.
GC Impact (GOGC=100 vs GOGC=800)
libatbus-go holds a small live heap while allocating per-message temporary buffers proportional to payload size, so default GOGC=100 spends 11%–74% of process CPU in GC. Raising GOGC to 800 across 6 workloads × 5 payload sizes (30 Linux runs):
Solid lines: GOGC=800; dashed lines: default GOGC=100; matching colors share the same workload.
| Workload | Payload | QPS delta | GC CPU share recv / send (default → GOGC=800) | Peak RSS recv / send (default → GOGC=800) |
|---|---|---|---|---|
| Plaintext | 200 B | +8.0% | 19.0% / 15.0% → 2.8% / 2.0% | 15.8 / 16.0 MB → 43.2 / 42.4 MB |
| Plaintext | 64 KB | +12.6% | 48.4% / 19.6% → 8.7% / 9.6% | 33.0 / 41.4 MB → 122.6 / 151.9 MB |
| Plaintext | 300 KB | +17.5% | 50.9% / 49.1% → 10.4% / 12.2% | 43.8 / 44.7 MB → 130.7 / 146.3 MB |
AES-128-GCM | 64 KB | +25.9% | 52.2% / 73.2% → 10.2% / 11.7% | 21.2 / 36.3 MB → 180.3 / 129.4 MB |
AES-128-GCM | 300 KB | +23.4% | 53.0% / 60.9% → 11.1% / 11.8% | 29.0 / 37.1 MB → 162.0 / 121.9 MB |
lz4 | 64 KB | +11.1% | 38.9% / 41.9% → 6.8% / 6.0% | 16.5 / 20.9 MB → 53.1 / 64.8 MB |
zstd | 1 KB | +45.2% | 35.4% / 64.9% → 8.7% / 23.2% | 20.7 / 85.3 MB → 55.3 / 199.7 MB |
Across all 30 runs, QPS rises by +10.4% on average (+8.2% median), while GC CPU drops from 11%–74% to 2%–23%. Large AEAD workloads gain 21%–26%. The tradeoff is 2.3x–8.5x higher peak RSS (40–225 MB per pair of nodes). Raise GOGC (or combine with GOMEMLIMIT) only on high-throughput central nodes, and keep the default on large numbers of small processes.
Same-Host IPC (Unix Domain Socket vs TCP)
Go does not implement shared memory (shm://); its same-host alternative on Linux is unix:// (named pipes pipe:// on Windows were not benchmarked). Unencrypted, uncompressed baseline:
| Payload | TCP (QPS / Throughput) | unix:// (QPS / Throughput) | unix:// vs TCP | C++ shm:// vs TCP |
|---|---|---|---|---|
| 200 B | 919.2K / 175.3 MB/s | 966.2K / 184.3 MB/s | +5.1% | 0.73x |
| 1 KB | 597.4K / 583.4 MB/s | 612.8K / 598.4 MB/s | +2.6% | 0.91x |
| 8 KB | 207.0K / 1.58 GB/s | 211.3K / 1.61 GB/s | +2.1% | 1.26x |
| 64 KB | 30.0K / 1.83 GB/s | 30.7K / 1.87 GB/s | +2.2% | 1.18x |
| 300 KB | 6.7K / 1.91 GB/s | 7.4K / 2.12 GB/s | +11.2% | 1.07x |
Gains stay within 2%–5% (the +11.2% at 300 KB sits within loopback run-to-run variance) because CPU is saturated by checksums, copies, Protobuf coding, and GC rather than TCP loopback syscalls. Encryption and compression continue to work normally over unix://.
Encryption and Compression Overhead
Encryption Algorithms
Linux (default settings), no compression.
| Cipher (uncompressed) | 200 B QPS | 1 KB QPS | 64 KB QPS / Throughput | 300 KB QPS / Throughput | vs plaintext (200 B / 64 KB / 300 KB) |
|---|---|---|---|---|---|
| None | 919.2K | 597.4K | 30.0K / 1.83 GB/s | 6.7K / 1.91 GB/s | — |
AES-128-GCM | 664.0K | 419.8K | 19.6K / 1.20 GB/s | 4.3K / 1.23 GB/s | -28% / -35% / -36% |
AES-192-GCM | 656.4K | 422.1K | 18.2K / 1.11 GB/s | 4.2K / 1.21 GB/s | -29% / -39% / -36% |
AES-256-GCM | 647.5K | 407.4K | 19.6K / 1.20 GB/s | 4.1K / 1.19 GB/s | -30% / -35% / -38% |
ChaCha20-Poly1305 | 609.4K | 384.9K | 15.6K / 972.0 MB/s | 3.4K / 989.4 MB/s | -34% / -48% / -49% |
ChaCha20 (raw) | 487.9K | 203.4K | 5.0K / 310.1 MB/s | 1.0K / 306.6 MB/s | -47% / -83% / -84% |
AES-GCMcosts 25%–39% across all sizes—flatter than C++ (-55% on small packets, -10% to -15% on large packets) because cipher work overlaps with other goroutines on small packets while sender GC share climbs on large packets (73% at 64 KB vs 20% plaintext). Key lengths 128 / 192 / 256 mostly stay within 3% of each other.ChaCha20-Poly1305trailsAES-GCMby 8%–21% and fits hosts without AES-NI. RawChaCha20lacks authentication and is much slower; disable it in production.
Compression and Combined Encryption
As in C++, payloads below 1,024 B (200 B / 256 B) skip compression, and the wire path always runs compress first, then encrypt (the Go data plane currently fixes the compression level to balanced, ignoring CompressionLevel).
Linux (default settings). 200 B* is below the 1 KB compression threshold, so compressed lines coincide with uncompressed lines of the same cipher.
| Compression (unencrypted) | 1 KB (QPS / Throughput) | 64 KB (QPS / Throughput) | 300 KB (QPS / Throughput) | Measured ratio (1 KB / 64 KB / 300 KB) | + AES-128-GCM (64 KB) |
|---|---|---|---|---|---|
| None | 597.4K / 583.4 MB/s | 30.0K / 1.83 GB/s | 6.7K / 1.91 GB/s | — | 19.6K / 1.20 GB/s |
snappy | 374.9K / 366.2 MB/s | 12.3K / 770.8 MB/s | 2.3K / 661.1 MB/s | 50.0% / 36.4% / 36.5% | 11.7K / 729.9 MB/s |
lz4 | 313.1K / 305.8 MB/s | 9.1K / 570.8 MB/s | 1.4K / 397.0 MB/s | 57.2% / 40.4% / 39.3% | 8.9K / 555.8 MB/s |
zlib | 7.2K / 7.0 MB/s | 1.9K / 116.7 MB/s | 452 / 132.5 MB/s | 32.0% / 21.7% / 21.9% | 1.8K / 113.9 MB/s |
zstd | 4.5K / 4.4 MB/s | 1.6K / 98.6 MB/s | 565 / 165.6 MB/s | 40.2% / 25.9% / 25.4% | 1.3K / 83.1 MB/s |
- Use only
snappyorlz4for compression: both sustain 20%–63% of plaintext throughput, withsnappyroughly 20% faster thanlz4(35% faster at 64 KB, 66% faster at 300 KB) and slightly better compression ratio. Adding AEAD encryption on top has minimal impact because sender compression dominates CPU. zstdandzlibare two orders of magnitude slower and unsuitable for production:zstddrops to 4.5K msg/s at 1 KB (vs 183K in C++ on the same host). Profiling showsatframe-utils-go's compression adapter constructs a new encoder per message (EncodeAllconsumes 41% of sender CPU, of which only 3.6% is actual encoding, while zero-initialization drives 65% GC overhead). In single-core pinned runs, 1 KBzstdruns 3.5x faster than under the 12-core default (15.8K vs 4.5K msg/s), indicating that multi-core GC amplifies short-lived large-object allocation costs. Per-message encoder construction also raiseszstdsender private memory to 4x plaintext (see zstd Sender Memory Overhead).
Multi-Node Fan-In Scaling (2 to 1000 Nodes)
Fan-in runs pin one receiver to dedicated CPUs 0–3 (GOMAXPROCS=4) handling 1 / 9 / 99 / 999 sender processes sharing CPUs 4–11 (GOMAXPROCS=1 per sender), across 20 combinations × 6 payload sizes (480 runs total, 467 valid). Isolating receiver cores from senders is required at high connection counts so hundreds of senders do not starve the receiver.
Linux (CPU-pinned), aggregate measurements on the GOMAXPROCS=4 receiver.
Aggregate throughput peaks at 10 nodes (9 senders saturate the receiver, rising 46%–134% over 2 nodes). At 1000 nodes, plaintext sustains 1.14M msg/s (200 B) and 2.43 GB/s (300 KB), 17%–36% below the 10-node peak (receiver CPU reaches 371% at 8 KB and 388% at 32 KB, near the 4-core ceiling; small packets use 241%–298% and bottleneck in the serial node loop; the exact scheduling hotspot across 1000 nodes has not yet been profiled). Across all 467 valid runs, the maximum receiver sampling interval remained 1.0 s, and 1000-node registration finished within 0.2–0.8 s.
200 B* and 256 B* fall below the 1 KB compression threshold and are not compressed; dotted lines show 2-node references, and all other lines are 1000-node measurements.
As in C++, parallel compression across senders shifts the bottleneck to receiver decompression: at 1000 nodes and 300 KB, lz4 climbs 4.58x over 2 nodes (6.6K / 1.90 GB/s) and snappy climbs 2.84x (6.7K / 1.93 GB/s).
Same-host Linux multi-node plaintext comparison between Go (4-core receiver) and C++ (1-core receiver), including receiver CPU-normalized per-core ratios:
| Total nodes | 200 B: C++ / Go (Go %) | 1 KB: C++ / Go (%) | 8 KB: C++ / Go (%) | 300 KB: C++ / Go (%) | Receiver 1-core normalized Go / C++ |
|---|---|---|---|---|---|
| 2 | 3.73M / 894.8K (24%) | 1.67M / 552.1K (33%) | 227.6K / 149.3K (66%) | 9.9K / 7.1K (71%) | 29%–56% |
| 10 | 3.78M / 1.41M (37%) | 1.52M / 1.10M (72%) | 263.9K / 349.4K (132%) | 9.8K / 10.3K (105%) | 18%–45% |
| 100 | 3.69M / 1.21M (33%) | 1.47M / 988.4K (67%) | 259.3K / 304.6K (118%) | 8.9K / 9.6K (108%) | 12%–35% |
| 1000 | 3.70M / 1.14M (31%) | 1.39M / 888.6K (64%) | 243.6K / 223.7K (92%) | 9.4K / 8.5K (90%) | 13%–26% |
- 13 excluded runs (all at 1000 nodes): 4
zstd300 KB runs were stopped when per-message encoder allocations across 999 senders pushed available RAM below the 2 GB guard (root cause in zstd Sender Memory Overhead); 4zstd1 KB and 4zlib1 KB runs experienced mid-run receiver stalls (backlog drained only after senders exited); 1AES-128-GCM + lz48 KB run had only 2 s of steady-state samples (below the 3 s threshold).
Memory Analysis and Tuning
To explain why receiver RSS reached 1.33 GB at 1000 nodes / 300 KB (vs 334 MB for C++ on the same host) and why zstd 300 KB triggered the 2 GB available-memory guard at 1000 nodes, 30–90 s runs with per-second live-heap sampling and forced-GC heap profiles were collected on the same host. Neither issue is a memory leak.
Receiver Memory Breakdown and GOMEMLIMIT Tuning
Live-heap stability across sustained traffic and repeated connect/disconnect cycles:
| Diagnostic scenario | Post-GC live heap under load | Heap target | RSS | Key findings |
|---|---|---|---|---|
| 1000 nodes, 300 KB, 90 s | 620–755 MB (no upward trend from 10 s to 91 s) | 1.25–1.5 GB | 1.2–1.36 GB (peak 1.41 GB) | 760K messages processed, 9 GC cycles/s; drops to 82 MB after senders exit |
| 1000 nodes, 200 B, 30 s | Flat at 205 MB (≤ 2 MB variance) | 413–417 MB | 336 MB | 37.7M messages processed (< 1 B per message) |
| 2 nodes, 300 KB, 30 s | 1–13 MB | 2–26 MB | 16–35 MB | Low-connection reference |
| 3 cycles of "300 senders connect → send → disconnect" | 230–300 MB per cycle | — | 17–24 MB after each cycle | Live heap returns to 1 MB after disconnect; goroutines drop from 1205 back to 5 |
Breakdown of the 667 MB post-GC live heap at 30 s (1000 nodes, 300 KB):
| Component | Size | Share |
|---|---|---|
| In-flight large frame buffers (~1,330 × 300 KB, ~1.3 per data connection) | 400 MB | 60% |
| Per-connection 64 KB read buffers (1,998 connections) | 122 MB | 18% |
| Connection structs (7 KB header buffer + 1,024-slot write queue channel) | 76 MB | 11% |
| Queued and being-decoded Protobuf copies in the node loop | 61 MB | 9% |
- Fixed overhead is ~97 KB per connection (~200 MB across 2,000 connections, matching the flat 205 MB live heap at 200 B). Large payloads add in-flight frame buffers on top, and default
GOGC=100lets the heap grow to 2x the live heap before triggering GC, keeping RSS near 1.3 GB. - Reducing RSS with
GOMEMLIMIT: four runtime settings measured at 1000 nodes / 300 KB (30–90 s each):
| Runtime setting | QPS | Avg / peak RSS | GC cycles/s | GC CPU share |
|---|---|---|---|---|
Default GOGC=100 | 9,231 | 1,282 / 1,407 MB | 8.9 | 8.1% |
GOMEMLIMIT=1GiB | 9,160 | 893 / 925 MB | 17.7 | 14.1% |
GOGC=50 | 8,935 | 931 / 967 MB | 16.7 | 14.0% |
GOMEMLIMIT=600MiB (below live heap) | 5,909 | 566 / 621 MB | 69.5 | 42.1% |
Setting GOMEMLIMIT above the live heap (such as 1GiB) cuts RSS by roughly 30% with QPS unchanged within noise (GOGC=50 performs similarly). Setting it below the live heap (600MiB) causes near-continuous GC and drops QPS by 36%. Code-level reductions remain possible in future work: pooling read buffers (up to ~120 MB saved), shrinking write-queue channels, and capping in-flight large frames or growing frame buffers incrementally as bytes arrive (up to ~300 MB saved, subject to throughput verification).
zstd Sender Memory Overhead
Measurements across 300 senders (GOMAXPROCS=1 pinned each) transmitting 300 KB payloads:
| Workload & setting (300 senders, 300 KB) | Private RAM / sender | Post-GC live heap | Heap target | Alloc / msg | GC cycles / msg | Aggregate QPS |
|---|---|---|---|---|---|---|
| Plaintext | 6.2 MB | 2.0 MB | 4.3 MB | 0.6 MB | 0.27 | 10,041 |
zlib | 6.5 MB | 1.9 MB | 4.5 MB | 1.7 MB | 0.72 | 1,079 |
zstd, default GOGC=100 | 23.9 MB | 10.1 MB | 20.3 MB | 9.7 MB | 1.0 | 1,543 |
zstd, GOGC=50 | 20.6 MB | 10.0 MB | 15.3 MB | 9.7 MB | 1.0 | 1,660 |
zstd, GOMEMLIMIT=32MiB | 23.4 MB | 10.1 MB | 20.4 MB | 9.7 MB | 1.0 | 1,263 |
zstd, GOMEMLIMIT=14MiB | 10.9 MB | 9.0 MB | 9.6 MB | 9.7 MB | 3.5 | 1,391 |
- Root cause:
atframe-utils-go's compression adapter callszstd.NewWriteron every message. Atbalanced, each writer allocates an 8 MB history window (82% of cumulative heap allocations) plus ~1.6 MB of encoder tables, totaling 9.7 MB per 300 KB message. Because each sender spends most of its time encoding, one encoder is always live (~10 MB live heap), and defaultGOGC=100doubles headroom to ~24 MB private RAM per sender (4x plaintext; steady across 30 s and across 300 / 600 senders, confirming no leak). Across 999 senders that equals ~24 GB, driving available host RAM from 24.4 GB down to 2.5 GB within 3 seconds of start. - Mitigation and permanent fix:
GOMEMLIMITtakes effect only below the heap target (32MiBhas no effect;14MiBcuts private RAM by 54% to 10.9 MB at ~10% QPS cost). The real fix is reusing encoders inatframe-utils-go: standalone microbenchmarks of a 300 KB message (GOMAXPROCS=1,balanced) show encoder reuse cuts per-message allocations from 9.2 MB to 0.30 MB (and time from 1.02 ms to 0.81 ms), while shrinking the window from 8 MB to 512 KB keeps the 300 KB compression ratio identical (25.4%). Thezstdreceiver is unaffected (0.85 MB/msg allocated, 7.6 MB private RAM in a pair).
Test Boundaries and Open Anomalies
Account for these limits during capacity planning:
- Communication library only: excludes
atsf4g-gobusiness scheduling (ActorExecutor), RPC envelopes, object routing, observability, and database I/O; validate production capacity by replaying realistic business RPC traffic. - No latency percentiles or multi-hop / full-duplex traffic: star-topology loopback unidirectional saturation tests exclude P50/P99 latency, physical NIC/WAN loss, full-duplex load, and multi-hop
atproxyforwarding. - Runtime and payload dependence: GC share and scheduling depend on Go 1.27.4 and should be re-measured after Go upgrades; compression ratios and throughput use compressible JSON-like text, whereas high-entropy data yields lower ratios for the same CPU cost.
Four observed anomalies remain open for follow-up profiling:
zstd/zlibare two orders of magnitude slower on 12 cores while running 3.5x faster on 1 core (per-message encoder creation is the trigger; multi-core GC amplification on short-lived large objects is suspected).- Mid-run receiver stalls on 1000-node
zstd/zlib1 KB runs (data stalls betweenSendDatareturn and the receiver socket, likely because 999GOMAXPROCS=1senders oversubscribing 8 cores starve writer goroutines under extreme harness saturation on modest test hardware). - Native Windows large payloads reach only 21%–44% of Linux with receiver GC CPU at 89% (possibly tied to Windows large-block allocation/free overhead).
- At 1000 nodes, steady-state receiver throughput after kernel buffers fill and flow control engages is 20%–30% faster than during the initial buffer-filling phase (likely fuller reads and fewer wakeups).
Raw Data
All six summary CSV files are downloadable below; complete build commands, full tables, and offline SVGs live in atframework/libatbus-go/docs/Benchmark.md and the GitHub benchmark report (memory diagnostics are summarized in this page and the upstream report without archived raw traces).
| Dataset | Files | Description |
|---|---|---|
| Single-pair TCP baseline | Linux CSV · Windows CSV | Full metrics across 110 runs per platform |
| Same-host IPC | Linux unix:// CSV | 5 unencrypted, uncompressed comparison runs |
| GC comparison | Linux GOGC=800 CSV | 30 runs across 6 workloads × 5 payload sizes |
| Single-core pinned | Linux GOMAXPROCS=1 CSV | 30 runs with 1 core pinned per side |
| Multi-node fan-in | Linux 467-run CSV | Full metrics across 2 / 10 / 100 / 1000 nodes |
Summary
libatbus-go completes the libatbus v2 protocol stack in Go and establishes same-host baselines against C++: single-pair Linux TCP reaches 919.2K msg/s (200 B) and 1.91 GB/s (300 KB), with single-core pinned runs at 25%–33% of C++ on small packets and 50%–66% on large packets; 1000-node fan-in with a 4-core pinned receiver reaches 1.14M msg/s and 2.43 GB/s. Memory diagnostics confirm that neither the 1.33 GB receiver RSS at 1000 nodes nor high zstd sender memory is a leak—they stem respectively from in-flight large frames plus ~97 KB/connection live heap under GOGC=100, and atframe-utils-go allocating a fresh 8 MB-window zstd writer per message.
For production deployments, enable AES-128/256-GCM, keep compression off on high-bandwidth intranets, choose snappy or lz4 on bandwidth-limited links (avoiding zstd/zlib until atframe-utils-go reuses encoders), isolate receiver CPU cores, and configure GOGC and GOMEMLIMIT (above the live heap) on throughput-critical nodes.