Skip to content

Improve batch message acking by removing batch message tracker - #1424

Merged
merlimat merged 6 commits into
apache:masterfrom
sijie:improve_acking_on_batch_messages
Mar 28, 2018
Merged

Improve batch message acking by removing batch message tracker#1424
merlimat merged 6 commits into
apache:masterfrom
sijie:improve_acking_on_batch_messages

Conversation

@sijie

@sijie sijie commented Mar 23, 2018

Copy link
Copy Markdown
Member

Motivation

client is maintaining a batch message tracker to track batch messages for acknowledge. if the application is using Failover subscription and doesn't ack the messages at all, the message id objects will be accumulating in the client.

Modifications

Move the bitset as part of BatchMessageIdImpl and remove batch message tracker

@sijie sijie added this to the 2.0.0-incubating milestone Mar 23, 2018
@sijie sijie self-assigned this Mar 23, 2018
@sijie
sijie requested review from merlimat and rdhabalia March 23, 2018 03:08

@merlimat merlimat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, refactoring that logic into own class was long overdue. I think there is a part missing when handling cumulative acks and there seems to be legit test failures.

}

// bitset shared across messages in the same batch.
private final BitSet bitSet;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have many of these objects, we could inherit from BitSet to avoid an extra object.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm then I have to change how BatchMessageAckerDisabled and such. I think this change here removes the hashmap, which already remove bunch of allocations per batch message. It might be better to hide bitset behind the acker and make batch message acker a recycle object, which we can reuse those objects.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can do that later

if (batchMessageAckTracker.isEmpty()) {
return;
}
MessageIdImpl lowerKey = batchMessageAckTracker.lowerKey(message);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how this logic to remove all entries from previous batches (when doing cumulative ack) has been replaced.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@merlimat the first PR has a wrong logic on cumulative ack. I fixed it at ceb7b45

@merlimat merlimat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice improvement!

@merlimat
merlimat requested a review from jai1 March 24, 2018 05:14
@sijie

sijie commented Mar 26, 2018

Copy link
Copy Markdown
Member Author

retest this please

@merlimat

merlimat commented Mar 26, 2018

Copy link
Copy Markdown
Contributor

@sijie can you merge with master? It already has the flaky test fixed.

@sijie

sijie commented Mar 27, 2018

Copy link
Copy Markdown
Member Author

merged latest master

@merlimat

Copy link
Copy Markdown
Contributor

@sijie

sijie commented Mar 28, 2018

Copy link
Copy Markdown
Member Author

@merlimat will take a look

@sijie

sijie commented Mar 28, 2018

Copy link
Copy Markdown
Member Author

@merlimat the problem is on getting batch size. fixed it at 42fa9e0

@merlimat
merlimat merged commit a141f30 into apache:master Mar 28, 2018
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Nov 30, 2022
Fixes apache#130

### Motivation

It's a catchup for apache/pulsar#1424

### Modifications

Migrate `BitSet` implementation from JDK. Though we have `vector<bool>`
or `boost::dynamic_bitset`, to support batch index ACK in future, it's
better to have the same method to convert a bit set to the underlying
long array.

Add `BatchedMessageIdImpl` to maintain a `BatchMessageAcker`, which is
shared by messages in the same batch. The acker is responsible to record
which messages are acknowledged. Only if all messages in the batch are
acknowledged will the message id be acknowledged.

For cumulative ack, use the number of removed batches to update the
stats. (TODO: record the batch size in the unacked message tracker in
future).
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Dec 1, 2022
Fixes apache#130

### Motivation

It's a catchup for apache/pulsar#1424

### Modifications

Migrate `BitSet` implementation from JDK. Though we have `vector<bool>`
or `boost::dynamic_bitset`, to support batch index ACK in future, it's
better to have the same method to convert a bit set to the underlying
long array.

Add `BatchedMessageIdImpl` to maintain a `BatchMessageAcker`, which is
shared by messages in the same batch. The acker is responsible to record
which messages are acknowledged. Only if all messages in the batch are
acknowledged will the message id be acknowledged.
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Dec 2, 2022
Fixes apache#130

### Motivation

It's a catchup for apache/pulsar#1424

### Modifications

Migrate `BitSet` implementation from JDK. Though we have `vector<bool>`
or `boost::dynamic_bitset`, to support batch index ACK in future, it's
better to have the same method to convert a bit set to the underlying
long array.

Add `BatchedMessageIdImpl` to maintain a `BatchMessageAcker`, which is
shared by messages in the same batch. The acker is responsible to record
which messages are acknowledged. Only if all messages in the batch are
acknowledged will the message id be acknowledged.

The stats for individual ACKs only updates after the whole batch are
acknowledged. Before this PR, each time the single message is
acknowledged, the stats increase by one.
BewareMyPower added a commit to apache/pulsar-client-cpp that referenced this pull request Dec 8, 2022
* Add BatchedMessageIdImpl to acknowledge batched messages

Fixes #130

### Motivation

It's a catchup for apache/pulsar#1424

### Modifications

Migrate `BitSet` implementation from JDK. Though we have `vector<bool>`
or `boost::dynamic_bitset`, to support batch index ACK in future, it's
better to have the same method to convert a bit set to the underlying
long array.

Add `BatchedMessageIdImpl` to maintain a `BatchMessageAcker`, which is
shared by messages in the same batch. The acker is responsible to record
which messages are acknowledged. Only if all messages in the batch are
acknowledged will the message id be acknowledged.

The stats for individual ACKs only updates after the whole batch are
acknowledged. Before this PR, each time the single message is
acknowledged, the stats increase by one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants