The original profiling harness under tests/integration uses TestNG classes as wrappers around a manually run
pulsar-perf workload. It is deprecated: TestNG discovery and test lifecycle add no useful test semantics to
long-running profiling scenarios, and make them harder to invoke and automate as standalone jobs. It is kept for its
existing v4 and v5 pulsar-perf scenarios while they are migrated. Add new scenarios, workload applications and
profiling support to the standalone launcher instead.
./gradlew :tests:integration:profilingIntegrationTest
./gradlew :tests:integration:profilingIntegrationTest --tests "*PulsarProfilingV4Test"profilingIntegrationTest builds the test image with async-profiler, relaxes the kernel's perf_event limits and
runs the test with retries off, as Profiling an integration test
describes. Both variants drive pulsar-perf against a single broker, and share everything but the client generation
and the topic domain through AbstractPulsarProfilingTest:
PulsarProfilingTest, which the task runs by default, drives a v5 scalable (topic://) topic with theproduceandconsumecommands.PulsarProfilingV4Testdrives a classicpersistent://topic with the same commands, for whichpulsar-perfpicks the v4 client. The v4 client rejects thetopic://domain, so the v4 client goes with the classic topic.
The runs aren't like-for-like: scalable topics split their segments under load (scalableTopicAutoScaleEnabled
defaults to true), so the v5 run profiles a topology that reshapes itself, while the v4 run's stays fixed. With
pulsar-profiling's defaults, a run sends 20 million messages, a bit over
a minute of load, and has to finish within three minutes, with both pulsar-perf commands exiting with zero, so that
a run that stalls or dies fails the test rather than passing as a finished profile.
Both variants write their recordings and command output under tests/integration/build/pulsar-profiling. The v4
run's pulsar-perf output, latency histograms, topic stats and metrics scrapes are suffixed -v4; the recordings
carry the container name, which embeds the test class name. The broker's profiler options come from
-Pinttest.asyncprofiler.opts. The runner doesn't render flame graphs;
Flame graphs of other recordings describes rendering them
from its recordings.
The runner's scenarios are in its test resources:
tests/integration/src/test/resources/org/apache/pulsar/tests/integration/profiling.
| Scenario | What it runs |
|---|---|
pulsar-profiling |
The runner's default settings, to start from |
read-completion-isolation |
500 producers on separate connections to one topic, with one Exclusive consumer. Read-completion queue isolation describes it and its variations: read-completion-isolation-shared, read-completion-isolation-failover, and the read-completion-isolation-64k-32k and read-completion-isolation-256k-128k channel watermarks |
key-shared-500x20 |
500 producers and 20 consumers on one Key_Shared subscription |
Select a scenario by its name, its file name without .yaml, in PULSAR_PROFILING_CONFIG, or pass the path of a
scenario file of your own there, an absolute one since Gradle runs the test in the integration module's directory.
Start with pulsar-profiling; omitted values keep the existing defaults. The sections correspond to the main
components of a run: cluster, load, profiling and output. Individual scalar values can be overridden for a
one-off run with an environment variable named with the prefix PULSAR_PROFILING_ or pulsar_profiling_ followed
by the value's path, its elements separated by underscores and in any case, as
Environment overrides describes for the launcher,
for example:
PULSAR_PROFILING_CONFIG=pulsar-profiling \
PULSAR_PROFILING_LOAD_NUMBER_OF_MESSAGES=1000000 \
./gradlew :tests:integration:profilingIntegrationTest --tests "*PulsarProfilingV4Test"The harness saves resolved-config.yaml, with inheritance and environment overrides applied, in the output
directory.
- For the v4 scenario, set
load.isolatedProducersorload.isolatedConsumersto create that many independent v4 client instances. The correspondingpulsar-perfcommand receives--isolated-clients, a v4-client option; the v5 scenario ignores these fields. The option is mutually exclusive with the regular producer test-thread option and with consumer listener-thread expansion. - Set
load.producerCountandload.consumerCountseparately: creating clients doesn't create producers or consumers. For v4 production,--num-producersremains the producer count per topic and is distributed across the isolated clients; when the counts differ, producers are assigned round-robin as evenly as possible. load.subscriptionTypeselects the subscription type;producerIoThreadsandconsumerIoThreadssize the shared client IO pools.maxOutstandingis per producer, not a global limit.- Set
load.batchingEnabled: trueto use pulsar-perf's default producer batching; the default isfalse, which keeps unbatched entry-by-entry measurements. load.messageKeyGenerationModemaps to pulsar-perf's--message-key-generation-mode:randomuses random integer keys,autoIncrementuses the sender's message counter, and an empty or null value omits keys. Override it withPULSAR_PROFILING_LOAD_MESSAGE_KEY_GENERATION_MODE.
key-shared-500x20 runs a single Key_Shared subscription with 500
producers and 20 consumers. It disables batching so that every entry has one key, and uses isolated clients with
shared resources on both sides. All consumers use the same subscription; receiverQueueSize is per consumer. The
standalone launcher runs the same workload as
iot-telemetry-max-rate.yaml, which also checks delivery and
per-key ordering and can profile off-CPU time.
Client profiling is optional and independent of broker profiling. Set profiling.producerOptions and/or
profiling.consumerOptions to async-profiler options, for example
event=cpu,interval=10ms,lock=0,alloc=2m,jfrsync=profile. An empty or null option disables that client's profiler.
Client recordings are named client-producer-*.jfr and client-consumer-*.jfr in the same output directory. The
harness grants native CPU profiling access only to enabled clients. To inspect lock contention without wall-clock
sampling overhead, omit wall and use lock=0 to record all supported lock events. Use the same options for the
baseline and the candidate; extra profiling has a measurement cost.
Broker-side variations need no dedicated environment switches: use cluster.brokerEnvs for write-buffer watermarks,
dispatcher batch size, broker and BookKeeper IO thread counts and PULSAR_GC, and cluster.brokerMemory for heap
and direct-memory limits and JVM properties such as allocator or transport selection. These maps let YAML scenarios
keep the complete configuration instead of relying on shell history.
Read-completion queue isolation runs on this runner: 500 producers on separate connections to one persistent topic, with one Exclusive consumer. It describes the scenario's variations and how to compare a baseline and a candidate.