Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve batch message acking by removing batch message tracker #1424

Merged
merged 6 commits into from
Mar 28, 2018

Conversation

sijie
Copy link
Member

@sijie sijie commented Mar 23, 2018

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
Copy link
Contributor

@merlimat merlimat left a comment

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
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
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
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
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
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

Copy link
Contributor

@merlimat merlimat left a comment

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
Copy link
Member Author

sijie commented Mar 26, 2018

retest this please

@merlimat
Copy link
Contributor

merlimat commented Mar 26, 2018

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

@sijie
Copy link
Member Author

sijie commented Mar 27, 2018

merged latest master

@merlimat
Copy link
Contributor

@sijie
Copy link
Member Author

sijie commented Mar 28, 2018

@merlimat will take a look

@sijie
Copy link
Member Author

sijie commented Mar 28, 2018

@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