[fix][broker][branch-4.0] Revert "[improve][broker] Reduce memory occupation of the delayed message queue (#23611)" #24429
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.
Motivation
Reason for Revert:
This PR has introduced a significant performance regression in the Pulsar broker.
The attached flame graph visually demonstrates increased CPU utilization and time
spent in the code paths related to DelayedDeliveryTracker and stream operations.
While the intention was to optimize memory usage, the current implementation
appears to have an adverse effect on CPU performance, leading to overall degraded
broker throughput and increased latency.
Impact:
This regression is impacting the stability and performance of our Pulsar clusters,
especially when you have large-scale delayed messages. Reverting the change will
allow us to restore the previous performance characteristics while we investigate
a more robust and performant solution for DelayedDeliveryTracker memory optimization.
Root Cause:
https://github.com/apache/pulsar/pull/23611/files#diff-f159b4e262ff6213bba19d20e6dc01d07ea8c19f4675524e4ceb1470f456e8fcR229-R231
Here is the change that caused this issue. Each message added to the
DelayedMessageTracker will call
getNumberOfDelayedMessages()
methodwhich will iterate the map defined in InMemoryDelayedDeliveryTracker
More contexts:
Flamegraph:

Jstack:
Modifications
Revert PR #23611 and the related PR #24035
Documentation
doc
doc-required
doc-not-needed
doc-complete