yunmaoQu commented on code in PR #23918:
URL: https://github.com/apache/pulsar/pull/23918#discussion_r1938881463
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java:
##########
@@ -218,9 +218,26 @@ public NavigableSet<Position> getScheduledMessages(int
maxMessages) {
return positions;
}
+ public boolean shouldSkipMessage(long ledgerId, long entryId) {
+ for (Long2ObjectMap<Roaring64Bitmap> ledgerMap :
delayedMessageMap.values()) {
+ Roaring64Bitmap entryIds = ledgerMap.get(ledgerId);
+ if (entryIds != null && entryIds.contains(entryId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public CompletableFuture<Void> clear() {
- this.delayedMessageMap.clear();
+ long cutoffTime = getCutoffTime();
Review Comment:
The decision to clear only expired indices in the clear() method of the
InMemoryDelayedDeliveryTracker is aimed at optimizing performance and
maintaining the logical state of the message delivery system.
By focusing on expired messages, we reduce the overhead associated with
clearing and re-adding valid messages, which enhances performance, especially
in scenarios with a high volume of delayed messages. This approach also allows
us to retain the state of valid messages, enabling more efficient message
delivery without needing to re-read them from storage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]