Skip to content

Conversation

dorjesinpo
Copy link
Collaborator

Messages that have fixed destination (such as PUSH/ACK/Relay PUT/Relay CONFIRM) do not have to go on Cluster thread - it is a bottleneck.
Instead, messages can go directly to mqbnet::Channel which enqueues them in thread-safe manner.
This needs synchronization based on AtomicGate which allows thread-safe, efficient checking of the cluster status and thread-safe opening/closing and draining.

PUSH and ACK require statistics update which we move from Cluster to Queue. For this reason the opening queue context (OpenQueueConfirmationCookie) conveys statistics from Queue to Cluster

@dorjesinpo dorjesinpo added the enhancement New feature or request label Dec 22, 2023
@dorjesinpo dorjesinpo requested a review from a team as a code owner December 22, 2023 20:39
@dorjesinpo dorjesinpo force-pushed the inline-push-ack branch 3 times, most recently from 6d2f55e to e21c4cd Compare December 26, 2023 01:57
@678098
Copy link
Collaborator

678098 commented Jan 4, 2024

Hi @dorjesinpo, looking

@678098 678098 assigned dorjesinpo and unassigned 678098 Jan 8, 2024
Copy link
Collaborator Author

@dorjesinpo dorjesinpo left a comment

Choose a reason for hiding this comment

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

Thank you for reviewing!

return; // RETURN
}

d_activeNode_p = activeNode;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because d_activeNode_p is (half) protected by d_gateActiveNode - it is safe to use if mqbc::GateKeeper::Status(d_gateActiveNode).isOpen()
d_activeNodeManager.activeNode() does not provide such guarantee.
I agree, this calls for refactoring, not in this PR, perhaps

@dorjesinpo dorjesinpo assigned 678098 and unassigned dorjesinpo Jan 10, 2024
@678098 678098 assigned dorjesinpo and unassigned 678098 Jan 10, 2024
@678098
Copy link
Collaborator

678098 commented Jan 10, 2024

@dorjesinpo thank you for fixes, added some comments in discussions and reassigned. You can assign this to @quarter-note later

@678098 678098 changed the title Inline Put, Push, Ack, Confirm Performance[MQB]: inline Put, Push, Ack, Confirm Aug 6, 2024
Copy link

@bmq-oss-ci bmq-oss-ci bot left a comment

Choose a reason for hiding this comment

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

Build 190 of commit 7d0e9c7 has completed with FAILURE

@pniedzielski pniedzielski removed the request for review from quarter-note December 18, 2024 22:32
@pniedzielski
Copy link
Collaborator

Assigning back to @dorjesinpo (to put in backlog)

@dorjesinpo dorjesinpo force-pushed the inline-push-ack branch 2 times, most recently from 4becc94 to 36c49a8 Compare March 9, 2025 17:32
@dorjesinpo dorjesinpo removed their assignment Mar 11, 2025
Signed-off-by: Vitaly Dzhitenov <[email protected]>
Signed-off-by: Vitaly Dzhitenov <[email protected]>
Signed-off-by: Vitaly Dzhitenov <[email protected]>
Signed-off-by: dorjesinpo <[email protected]>
Copy link

@bmq-oss-ci bmq-oss-ci bot left a comment

Choose a reason for hiding this comment

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

Build 2613 of commit 615eb54 has completed with FAILURE

Comment on lines +500 to +501
BSLS_ANNOTATION_UNUSED int partitionId,
BSLS_ANNOTATION_UNUSED const bmqp::ConfirmMessage& message)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
BSLS_ANNOTATION_UNUSED int partitionId,
BSLS_ANNOTATION_UNUSED const bmqp::ConfirmMessage& message)
BSLA_UNUSED int partitionId,
BSLA_UNUSED const bmqp::ConfirmMessage& message)

Recent changes

appData,
options,
state,
genCount);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there will be a segfault if we try to call a function that is not set. At least this is how it was in std c++ implementation.

Do you think it's worth handling empty d_putFunctor for this mock class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

BSLS_ASSERT_SAFE(d_putFunctor);

, d_isLeader(isLeader)
, d_isRestoringState(false)
, d_processor()
, d_putFunctor()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
, d_putFunctor()
, d_putFunctor(bsl::allocator_arg, d_allocator_p)

Need to handle possibly non-default allocator. This allocator will also be used in operator=

Comment on lines +153 to +154
// Signature of a functor method with one parameter, the processor
// handle on which it is being executed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this comment is misleading, since there is more than 1 parameter.
We can remove it or place the updated version in /// block before PutFunctor

case e_SUCCESS: BSLS_ANNOTATION_FALLTHROUGH;
case e_UNAVAILABLE: BSLS_ANNOTATION_FALLTHROUGH;
case e_INVALID_PRIMARY: BSLS_ANNOTATION_FALLTHROUGH;
case e_INVALID_GEN_COUNT: BSLS_ANNOTATION_FALLTHROUGH;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
case e_INVALID_GEN_COUNT: BSLS_ANNOTATION_FALLTHROUGH;
case e_INVALID_GEN_COUNT: BSLA_FALLTHROUGH;

Recent BSLA update

Comment on lines +1409 to +1410
const int id = message.queueId();
const int subId = message.subQueueId();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const int id = message.queueId();
const int subId = message.subQueueId();

Can use directly in 1 place below

int partitionId,
const bmqp::PutHeader& putHeader,
const bsl::shared_ptr<bdlbb::Blob>& appData,
BSLS_ANNOTATION_UNUSED const bsl::shared_ptr<bdlbb::Blob>& options,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
BSLS_ANNOTATION_UNUSED const bsl::shared_ptr<bdlbb::Blob>& options,
BSLA_UNUSED const bsl::shared_ptr<bdlbb::Blob>& options,

// CREATORS
QueueHandle::Subscription::Subscription(
unsigned int subId,
unsigned int downstreamSubQueueId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can subQueueId have a special negative value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No. There is bmqp::Protocol::k_DEFAULT_SUBSCRIPTION_ID (0)

Comment on lines +826 to +827
// cache producer stats to avoid lookup
d_producerStats.reset();
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment says about caching, but the code does the opposite and resets a shared_ptr.


mqbi::InlineResult::Enum
ClusterNodeSession::sendAck(const bmqp::AckMessage& ackMessage,
unsigned int queueId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
unsigned int queueId)
int queueId)

queueId can be negative?

@dorjesinpo
Copy link
Collaborator Author

closing in favor of #833

@dorjesinpo dorjesinpo closed this Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants