GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][test] Pass the client profiler's options to pulsar-perf in the profiling tests by merlimat · Pull Request #27428 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

#26619 added async-profiler recordings of the pulsar-perf clients to the legacy TestNG profiling runner
(PulsarProfilingTest, PulsarProfilingV4Test). When profiling.producerOptions or profiling.consumerOptions is
set, PulsarPerfContainer.enableProfiling puts the agent into the perf container's PULSAR_EXTRA_OPTS:

withEnv("PULSAR_EXTRA_OPTS", "-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints "
        + "-agentpath:/opt/async-profiler/lib/libasyncProfiler.so=start," + options
        + ",file=/testoutput/client-" + role + "-%t-%p.jfr");

produce() and consume() start pulsar-perf with DockerUtils.runCommandAsyncWithLogging, and since #24688 every
command that DockerUtils executes in a container gets an empty PULSAR_EXTRA_OPTS and OPTS, so that the
container's service options, such as a profiler agent, stay out of the tools that the tests run:

// Clear out PULSAR_EXTRA_OPTS and OPTS so that they don't interfere with the test
.withEnv(List.of("PULSAR_EXTRA_OPTS=", "OPTS="));

The exec's value replaces the container's, so pulsar-perf starts without the agent, and a run with client
profiling writes no client-producer-*.jfr or client-consumer-*.jfr, without any error.

For example, in a container of the test image started with -e PULSAR_EXTRA_OPTS=-Dmarker=1, the java command line
that docker exec -w /pulsar <container> bash -x bin/pulsar-perf produce --help traces has -Dmarker=1, and with
-e PULSAR_EXTRA_OPTS= -e OPTS=, the environment of DockerUtils' execs, it doesn't.

Modifications

PulsarPerfContainer.enableProfiling puts the agent options in a container variable of their own,
PERF_PROFILING_OPTS, which the execs leave alone, and makes produce() and consume() set PULSAR_EXTRA_OPTS
from it for pulsar-perf alone:

withEnv("PERF_PROFILING_OPTS", "-XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints "
        + "-agentpath:/opt/async-profiler/lib/libasyncProfiler.so=start," + options
        + ",file=/testoutput/client-" + role + "-%t-%p.jfr");
pulsarPerf = "PULSAR_EXTRA_OPTS=\"$PERF_PROFILING_OPTS\" /pulsar/bin/pulsar-perf";

Without client profiling options, enableProfiling returns early as before, and the commands stay as they were. The
environment of DockerUtils' execs doesn't change, so the other commands that the tests execute still start without
the containers' service options.

Verifying this change

  • Make sure that the change passes the CI checks.

The profiling tests are manual tests, which CI doesn't run. The change was verified with PulsarProfilingV4Test,
profiling both clients with event=cpu,interval=10ms over 2 million messages:

PULSAR_PROFILING_LOAD_NUMBER_OF_MESSAGES=2000000 \
PULSAR_PROFILING_PROFILING_PRODUCER_OPTIONS=event=cpu,interval=10ms \
PULSAR_PROFILING_PROFILING_CONSUMER_OPTIONS=event=cpu,interval=10ms \
./gradlew :tests:integration:profilingIntegrationTest --tests "*PulsarProfilingV4Test"
  • Before the change, the test passed and wrote the broker's recording, but no client recording.
  • With the change, it also wrote client-producer-<time>-<pid>.jfr and client-consumer-<time>-<pid>.jfr, with
    1,942 and 1,279 CPU samples, 65 % and 45 % of them in stacks with org.apache.pulsar.client or
    org.apache.pulsar.testclient frames. The logged pulsar-perf commands differ from the earlier ones only by the
    PULSAR_EXTRA_OPTS="$PERF_PROFILING_OPTS" prefix.
  • Without client profiling options, the test wrote the broker's recording only, and its pulsar-perf commands were
    the same as before the change, apart from the generated cluster and topic names.

./gradlew quickCheck and ./gradlew :tests:integration:checkstyleTest pass.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
[fix][test] Pass the client profiler's options to pulsar-perf in the …
4b44547
…profiling tests

PulsarPerfContainer.enableProfiling put the async-profiler agent into the
perf container's PULSAR_EXTRA_OPTS, but produce() and consume() start
pulsar-perf with DockerUtils.runCommandAsyncWithLogging, whose exec
environment sets PULSAR_EXTRA_OPTS and OPTS to empty. The exec's value
replaces the container's, so pulsar-perf ran without the agent and the
client-producer/client-consumer recordings were never written.

Keep the options in a container variable of their own, PERF_PROFILING_OPTS,
and start pulsar-perf with PULSAR_EXTRA_OPTS="$PERF_PROFILING_OPTS" when
the client is profiled. Without client profiling options the commands are
unchanged, and the environment of DockerUtils' execs stays as it is.
@merlimat merlimat added the area/test label Nov 6, 2026
codelipenghui
codelipenghui approved these changes Nov 6, 2026
View reviewed changes
@merlimat
merlimat merged commit 9f22e1c into apache:master Nov 6, 2026
81 of 83 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat mentioned this pull request Nov 7, 2026
[fix][test] Fix flaky SegmentOwnerStateTest by waiting for each layout creation's notification #27443
Merged
11 tasks
lhotari pushed a commit that referenced this pull request Nov 9, 2026
@merlimat @lhotari
[fix][test] Pass the client profiler's options to pulsar-perf in the …
f2d0116
…profiling tests (#27428)

(cherry picked from commit 9f22e1c)
@lhotari lhotari added release/5.0.2 cherry-picked/branch-5.0 labels Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@codelipenghui codelipenghui codelipenghui approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area/test cherry-picked/branch-5.0 release/5.0.2

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@merlimat @codelipenghui @lhotari
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.