Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ jobs:
# `cargo test` could assert. One added later stays out the same way, instead of arriving at 0% and failing
# this job for a change that could not have caused the drop.
#
# tools/perf is a default member, so that `cargo build --release` builds `pulsar-perf`, but it is a binary
# of the same kind: it is left out of the report instead.
#
# The generated protobuf code is left out of the report: there is far more of it than code written by hand,
# most of it for commands the client does not use yet, and the total would measure little else.
- name: Run the tests under cargo-llvm-cov
run: >
cargo llvm-cov --locked
--json --output-path target/coverage.json
--ignore-filename-regex '/apache-pulsar-protocol/src/proto/'
--ignore-filename-regex '/apache-pulsar-protocol/src/proto/|/tools/perf/'
- name: Summarize
id: summary
run: python3 .github/scripts/coverage-summary.py target/coverage.json
Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ default-members = [
"crates/apache-pulsar",
"crates/apache-pulsar-protocol",
"crates/apache-pulsar-testkit",
"tools/perf",
]

[workspace.package]
Expand Down
29 changes: 15 additions & 14 deletions docs/8-quality.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ a layout change. It is written so that it could later grow into a suite every SD
- `rustfmt`, `clippy` (with `await_holding_refcell_ref` denied), docs, and the minimum Rust version.
- `cargo-deny` for licenses (ASF third-party policy) and advisories.
- Integration tests against the broker container.
- Test coverage, measured with `cargo llvm-cov` on a pinned compiler, without the generated protobuf code. 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.
- Test coverage, measured with `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.

## 5. Releases

Expand All @@ -89,11 +89,12 @@ Two harnesses measure the client, and a recorded baseline is what later rounds c
- **Micro-benchmarks**, with criterion: `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.
- **End to end**, `tools/perf`: `perf produce` and `perf consume`, the producer's and the Queue consumer's throughput
and latency against a broker. Its options, its payloads and its 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.
- **End to end**, `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 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
Expand Down Expand Up @@ -145,11 +146,11 @@ reaches, 1 KiB messages of uppercase letters, batches of up to 1 ms, one segment

What it shows:

- **The client side is bound by its CPU, the producer and `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, `perf`'s share included: the next round looks for where the rest goes.
- **The client side is bound by its CPU, the producer and `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.
- **Large messages are bound by the broker:** at 10 KiB both clients store about 1 GB/s.
- **At a fixed rate, the latencies match**, this client's a little lower.
- **The thread-safe consumer's receives and acks each cross to its loop's thread**, so a loop receiving and
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# under the License.

[package]
name = "perf"
description = "Throughput and latency of the producer and the Queue consumer against a broker, as pulsar-perf measures them"
name = "pulsar-perf"
description = "Throughput and latency of the producer and the Queue consumer against a broker, as Java's pulsar-perf does"
version.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
23 changes: 12 additions & 11 deletions tools/perf/baseline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
# specific language governing permissions and limitations
# under the License.

# The performance baseline (docs/8-quality.md §6): this client's `perf` against Java's `pulsar-perf`, which drives the
# V5 client for a `topic://` topic. Each run has a standalone broker of its own, and its client runs in a container of
# its own on the broker's Docker network, so that both clients take the same path to the broker. Both are bounded by a
# 64 MiB client memory limit, the only bound a V5 producer has. `perf` drives the thread-safe client, with one event
# loop, from a thread of its own, as `pulsar-perf` sends from a thread of its own.
# The performance baseline (docs/8-quality.md §6): this client's `pulsar-perf` against Java's `pulsar-perf`, which
# drives the V5 client for a `topic://` topic. Each run has a standalone broker of its own, and its client runs in a
# container of its own on the broker's Docker network, so that both clients take the same path to the broker. Both are
# bounded by a 64 MiB client memory limit, the only bound a V5 producer has. This client's drives the thread-safe
# client, with one event loop, from a thread of its own, as Java's sends from a thread of its own.
#
# tools/perf/baseline.sh all the runs, each client in turn
# tools/perf/baseline.sh latency the runs whose name holds `latency`
Expand All @@ -44,10 +44,11 @@ cleanup() {
}
trap cleanup EXIT

# `perf` for Linux, built in the official Rust image, with its target and registry cached in volumes.
# This client's `pulsar-perf` for Linux, built in the official Rust image, with its target and registry cached in
# volumes.
docker run --rm -v "$ROOT:/src:ro" -v apr-perf-target:/target -v apr-perf-registry:/usr/local/cargo/registry \
-e CARGO_TARGET_DIR=/target -w /src "$RUST_IMAGE" cargo build --release --locked -p perf
docker run --rm -v apr-perf-target:/target -v "$BIN:/out" "$RUST_IMAGE" cp /target/release/perf /out/perf
-e CARGO_TARGET_DIR=/target -w /src "$RUST_IMAGE" cargo build --release --locked -p pulsar-perf
docker run --rm -v apr-perf-target:/target -v "$BIN:/out" "$RUST_IMAGE" cp /target/release/pulsar-perf /out/pulsar-perf

docker network create "$NET" >/dev/null

Expand Down Expand Up @@ -82,7 +83,7 @@ summary() {
}

rust() {
docker run --rm --network "$NET" -v "$BIN:/perf:ro" "$RUST_IMAGE" /perf/perf "$@" 2>&1 | summary
docker run --rm --network "$NET" -v "$BIN:/perf:ro" "$RUST_IMAGE" /perf/pulsar-perf "$@" 2>&1 | summary
}

java() {
Expand Down Expand Up @@ -116,8 +117,8 @@ produce() {
}

# A Queue consumer of each client reading `$2` messages of 1 KiB from the earliest, on a broker of its own, which
# `perf` fills first. This client's twice: on the thread-safe client, whose receives and acks each cross to its loop's
# thread, and on the local client, on the thread receiving.
# this client's `pulsar-perf` fills first. This client's twice: on the thread-safe client, whose receives and acks
# each cross to its loop's thread, and on the local client, on the thread receiving.
consume() {
local name=$1 messages=$2 client topic
[[ -z "$FILTER" || "$name" == *"$FILTER"* ]] || return 0
Expand Down
9 changes: 5 additions & 4 deletions tools/perf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
// specific language governing permissions and limitations
// under the License.

//! `perf`: the producer's and the Queue consumer's throughput and latency against a broker (docs/8-quality.md §6).
//! `pulsar-perf`: the producer's and the Queue consumer's throughput and latency against a broker (docs/8-quality.md
//! §6).
//!
//! Its options and its summary lines are those of Java's `pulsar-perf produce` and `pulsar-perf consume`, so that the
//! two clients compare line for line on the same broker:
//!
//! ```text
//! perf produce -u pulsar://localhost:6650 -s 1024 -m 1000000 -r 5000000 topic://public/default/perf
//! perf consume -u pulsar://localhost:6650 -m 1000000 topic://public/default/perf
//! pulsar-perf produce -u pulsar://localhost:6650 -s 1024 -m 1000000 -r 5000000 topic://public/default/perf
//! pulsar-perf consume -u pulsar://localhost:6650 -m 1000000 topic://public/default/perf
//! ```

use std::pin::pin;
Expand All @@ -42,7 +43,7 @@ use hdrhistogram::Histogram;
const PER_MESSAGE_OVERHEAD: u64 = 1024;

#[derive(Parser)]
#[command(about = "Throughput and latency of the producer and the Queue consumer, as pulsar-perf measures them")]
#[command(about = "Throughput and latency of the producer and the Queue consumer, as Java's pulsar-perf measures them")]
struct Args {
#[command(subcommand)]
command: Command,
Expand Down
Loading