Repository navigation
Description
Search before reporting
- I searched in the issues and found nothing similar.
Read release policy
- I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
User environment
Experimental branch from current master
In the commit, the problem is fixed. Repo instructions will be later.
Issue Description
The test creates small entries with only 128 bytes for each entry to stress entry creation.
Batching is turned off. Consuming is very slow with default settings and consuming cannot keep up with producing that is over 350000 msgs/s (on Mac M3 Max running Docker with OrbStack).
The consuming speed is only about 11000 msgs/s.
Error messages
No errors
Reproducing the issue
The issue can be reproduced with https://github.com/lhotari/pulsar/blob/a85ac6fbfb3b763f7eaa4f44e232536748119ca4/tests/integration/src/test/java/org/apache/pulsar/tests/integration/profiling/PulsarProfilingTest.java and changes in the branch https://github.com/lhotari/pulsar/tree/lh-small-entry-size-performance-issue .
Please notice that the problem in the branch is fixed. The problem can be reproduced by reverting the last commit lhotari@a85ac6f
This "fixed" the performance issue:
diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/profiling/PulsarProfilingTest.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/profiling/PulsarProfilingTest.java
index a9f718103bf2f..a8d2ec3a5e32f 100644
--- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/profiling/PulsarProfilingTest.java
+++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/profiling/PulsarProfilingTest.java
@@ -219,7 +219,8 @@ protected PulsarClusterSpec.PulsarClusterSpecBuilder beforeSetupCluster(String c
brokerEnvs.put("dispatcherRetryBackoffMaxTimeInMs", "0");
//brokerEnvs.put("PULSAR_PREFIX_subscriptionKeySharedUseClassicPersistentImplementation", "true");
//brokerEnvs.put("PULSAR_PREFIX_subscriptionSharedUseClassicPersistentImplementation", "true");
- brokerEnvs.put("dispatcherMaxReadBatchSize", "1000");
+ brokerEnvs.put("dispatcherMaxReadBatchSize", "10000");
+ brokerEnvs.put("dispatcherMaxReadSizeBytes", "10000000");
brokerEnvs.put("dispatcherDispatchMessagesInSubscriptionThread", "false");
brokerEnvs.put("dispatcherMaxRoundRobinBatchSize", "1000");
specBuilder.brokerEnvs(brokerEnvs);Additional information
Although the changein the repro branch "fixed" the issue, it's not a suitable fix. The root cause of the problem should be addressed. It's possible that it's related to entry size estimation changes that have been made fairly recently.
Are you willing to submit a PR?
- I'm willing to submit a PR!
Activity
lhotari commentedon Sep 3, 2025
Now I see the correlation. When
maxPendingPublishRequestsPerConnectionvalue is reduced, the consuming will be more responsive with the tradeoff that latency increases and throughput goes down for both producing and consuming.In the above case, I had increased
maxPendingPublishRequestsPerConnectionto10000from the default1000to improve producing throughput.This seems to be a problem where the produced entries and the consuming (dispatching) are constrained on the same thread and get queued up in the same queue.
There's also #23865. Currently
readMoreEntriesgets called in random Pulsar IO threads, which doesn't make much sense.lhotari commentedon Sep 3, 2025
The problem persists even with
maxPendingPublishRequestsPerConnection=1000, after the consumption rate drops, it's never able to catch up.lhotari commentedon Sep 3, 2025
With
dispatcherMaxReadBatchSize=1000, consuming is able to keep up.it seems that
dispatcherMaxReadBatchSizeneeds to be close tomaxPendingPublishRequestsPerConnectionvalue. This is also a sign that some queues are shared between producing and consuming, although there should only be a need when actual BK reads are made and the entries aren't found in the cache.