Previous: 7. Public API. Next: 9. Classic API.
Logs go through tracing. Spans carry the identifiers that tie events together: the topic, the producer or consumer name, the subscription, and the connection's addresses. Segment ids appear in logs only, never in the API.
Metrics are recorded through nanometer: each loop has its own local handles, so recording costs no synchronization, and the exporter sums them. The application passes an OpenTelemetry MeterProvider, and the client depends only on the opentelemetry API crate. Metric names and attributes are the Java client's, so dashboards work for both. The Java instrumentation in pulsar-client defines, among others:
pulsar.client.connection.opened, .closed and .failed;pulsar.client.lookup.duration;pulsar.client.producer.message.send.duration, pulsar.client.producer.message.pending.count;pulsar.client.consumer.message.received.count, pulsar.client.consumer.message.ack;pulsar.client.memory.buffer.usage.The full list is taken from the Java sources when metrics are implemented. Metrics of state that spans loops, such as the client memory buffer, use nanometer's shared gauges.
| Layer | What it covers | How |
|---|---|---|
| Unit | Routing, layout application, the producer's retire, park and hold logic, position vectors, ack tracking, batching and bucketing, MessageId and Checkpoint encoding. | Plain tests on the state machines (2 §2). |
| Simulated broker | Protocol flows and failures: handshakes, lookups and redirects, splits and merges in the middle of produce and consume, reassignments, mode flips, reconnects, timeouts. | apache-pulsar-testkit: a scripted broker built on the protocol crate‘s codec, over in-memory connections, on a controlled clock. Deterministic, with no sockets or sleeps. For scalable topics, scalable::World simulates a cluster (topics, layouts, segments, producers, and the admin’s split, merge and terminate, with the 5.0.1 broker‘s ordering of receipts, closes and layout pushes), and producer::Harness drives the producer’s state machine against it as the driver would. |
| Driver | That the compio layer moves bytes and time correctly: concurrent reads and writes, plain and TLS, reconnects, coalescing, keepalive, the loops of the thread-safe client, the producer task, the memory limit, the three APIs. | The same simulated broker, and the simulated cluster, behind loopback sockets, in apache-pulsar's own tests. Real time, so they wait for states with generous deadlines, never for fixed delays. |
| Integration | The client against a real broker. | The released apachepulsar/pulsar image (5.0.1 today), with a proxy, TLS, token and mTLS authentication, started from the test harness with testcontainers (crates/apache-pulsar/tests/integration). Admin operations (a split during traffic, a partitioned topic, a namespace policy) go through pulsar-admin in the broker container, and the Java client there reads back what the Rust producer stored. cargo test skips them; they need Docker. A broker built from master (./gradlew docker) when a test needs an unreleased change. |
| Cross-language | Same routing, and identifiers that move between SDKs. | Routing vectors and golden MessageId and Checkpoint bytes generated by the Java client, plus Java ⇄ Rust produce and consume tests. |
The scenarios of the Java V5 tests are ported, not their code:
pulsar-client-v5/src/test: about 190 tests, mostly unit tests over Java internals with mocks. They map to unit and simulated-broker tests.apache/pulsar use the V5 API, mostly the V5*Test and ScalableTopic*Test classes in pulsar-broker. They map to integration tests.tests/PORTING.md lists each Java test class with its Rust counterpart and status, so coverage can be tracked. Many broker tests trigger splits and merges, or look at broker state. Against a container, that needs the admin REST API, so the test harness gets a small admin client of its own (1 §5).
The spec's test guidance (conformance §5) becomes a named suite: routing vectors, a split or merge during active produce and consume, a broker failover, cumulative ack across segments, and checkpoint round trips across a layout change. It is written so that it could later grow into a suite every SDK runs.
rustfmt, clippy (with await_holding_refcell_ref denied), docs, and the minimum Rust version.cargo-deny for licenses (ASF third-party policy) and advisories..rat-excludes lists.cargo llvm-cov on a pinned compiler, without the generated protobuf code or tools/perf. The job lists the lines and regions no test runs, such as the error branch of a ?, and fails a pull request whose line coverage is below its base's. A drop needs a test for what the change added, or a reason in the pull request for leaving the line unreached.Releases follow the ASF process: a signed source release, a vote on dev@, and then publishing to crates.io from the voted source. Every source file carries the ASF license header, and the repository has LICENSE and NOTICE files. The steps, and the scripts in build-support/ they use, are in RELEASE.md.
Two harnesses measure the client, and a recorded baseline is what later rounds compare with.
cargo bench -p apache-pulsar-protocol. The producer's state machine routes, batches, encodes and matches the receipts of 1000 keyed messages, sans IO, batched or not; each codec compresses a batch of 1000 small JSON messages, and the consumer decompresses it and splits it into its messages.tools/perf: this client‘s pulsar-perf, which cargo build --release builds. pulsar-perf produce and pulsar-perf consume measure the producer’s and the Queue consumer‘s throughput and latency against a broker. Their options, their payloads, their reports every 10 seconds and their summary lines are those of Java’s pulsar-perf, which drives the V5 client for a topic:// topic, so that the two compare line for line. tools/perf/baseline.sh runs both, each in a container of its own on the broker's Docker network, against a standalone broker of its own for each run, both bounded by a 64 MiB client memory limit, the only bound a V5 producer has.Still to measure: loop counts, with producers spread over the thread-safe client's loops, and pulsar-rs, which has no scalable topics, so persistent:// topics through the migration bridge, from a harness on tokio. An OpenMessaging Benchmark driver can follow once the API is stable.
Recorded on 2026-11-21, at M6, on an Apple M5 Pro (18 cores, 48 GiB) on mains power, macOS 26, with Rust 1.99 in release builds. Docker Desktop‘s VM (10 CPUs, 19.5 GiB) ran the broker, apachepulsar/pulsar:5.0.1 standalone, and both clients, Java’s on Corretto 25. One laptop for the broker and both clients: the two runs of each case agree within about a tenth, but earlier ones, on battery power, came out up to a half lower, so the end-to-end numbers compare the clients roughly. A regression shows first in the micro-benchmarks, whose intervals are within a few percent.
Micro-benchmarks, on the host, one thread:
| Benchmark | Time | Throughput |
|---|---|---|
| Producer, 100 B messages, batched | 255 ns a message | 3.9 M messages/s |
| Producer, 1 KiB messages, batched | 285 ns a message | 3.5 M messages/s |
| Producer, 100 B messages, unbatched | 1.00 µs a message | 1.0 M messages/s |
| Producer, 1 KiB messages, unbatched | 0.98 µs a message | 1.0 M messages/s |
| Consumer, decoding an uncompressed batch of 1000 messages | 43 µs a batch | 1.9 GiB/s |
| Codec, on a batch of 1000 messages of JSON (87 KB) | Compress | Decompress and split |
|---|---|---|
| LZ4 | 2.5 GiB/s | 1.5 GiB/s |
| Snappy | 2.5 GiB/s | 1.4 GiB/s |
| ZSTD, level 3 | 1.5 GiB/s | 1.2 GiB/s |
| ZLIB, default level | 130 MiB/s | 990 MiB/s |
End to end, tools/perf/baseline.sh, twice, each cell giving both runs: 20 s at the highest rate each client reaches, 1 KiB messages of uppercase letters, batches of up to 1 ms, one segment, unless the run says otherwise.
| Run | This client, msg/s | Java's, msg/s |
|---|---|---|
| Produce | 453k / 463k | 929k / 997k |
| Produce, four segments | 409k / 420k | 892k / 945k |
| Produce, 100 B | 659k / 659k | 2.01M / 2.04M |
| Produce, 10 KiB | 99.7k / 99.7k | 90.1k / 103k |
| Produce, without batching | 178k / 179k | 426k / 444k |
| Produce, LZ4, near-empty entries | 531k / 539k | 1.89M / 1.89M |
| Produce, ZSTD, near-empty entries | 564k / 583k | 1.61M / 1.52M |
| Consume 4M messages, receiving and acknowledging each | 18.3k / 18.3k thread-safe, 331k / 336k local | 411k / 423k |
| Latency at 10,000 msg/s, 60 s after 10 s of warm-up | p50 | p99 | p99.9 | Max |
|---|---|---|---|---|
| This client | 1.48 / 1.50 ms | 2.42 / 2.41 ms | 2.87 / 2.72 ms | 6.2 / 6.7 ms |
| Java's | 1.62 / 1.62 ms | 2.75 / 2.77 ms | 2.99 / 3.69 ms | 11.9 / 9.6 ms |
What it shows:
pulsar-perf driving it. In a separate 1 KiB run, sampled with docker stats, this client used 150–180% of a core, its loop‘s thread and the one making the load, for about 500k msg/s, and 100% on the local client, both on one thread, for about 400k. Java’s used under one core for about 990k, and the broker had room every time. The state machine takes under 0.3 µs of a message, the micro-benchmarks say, out of about 3 µs of CPU in all, pulsar-perf's share included: the next round looks for where the rest goes.pulsar-perf's, so a batch compresses to almost nothing. The micro-benchmarks measure the codecs.apache/pulsar commit, or use a published nightly image if one exists?pulsar-admin alone?