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

Feat[MQB]: Add log with session/queue operations time #414

Merged
merged 27 commits into from
Sep 6, 2024

Conversation

alexander-e1off
Copy link
Collaborator

Augment the logs of broker operations such as start/stop client session as well as open/configure/close queue to contain the human friendly (for easy log read) as well as the nanoseconds time of all operations (in both success and failures).
Log looks like this:

INFO mqbnet_tcpsessionfactory.cpp:899 Open session 'bmqtool.tsk:437032@127.0.0.1~localhost:50912' took: 1.06 ms (1061315 nanoseconds)

INFO mqba_clientsession.cpp:1127 bmqtool.tsk:437032@127.0.0.1~localhost:50912: Open queue 'bmq://bmq.test.persistent.priority/my-first-queue' took: 14.20 ms (14203096 nanoseconds)

INFO mqba_clientsession.cpp:1127 bmqtool.tsk:437032@127.0.0.1~localhost:50912: Configure queue 'bmq://bmq.test.persistent.priority/my-first-queue' took: 1.05 ms (1047816 nanoseconds)

INFO mqba_clientsession.cpp:1127 bmqtool.tsk:437032@127.0.0.1~localhost:50912: Close queue 'bmq://bmq.test.persistent.priority/my-first-queue' took: 3.28 ms (3277330 nanoseconds)

INFO mqba_clientsession.cpp:1127 bmqtool.tsk:437032@127.0.0.1~localhost:50912: Close session took: 1.96 ms (1960864 nanoseconds)

@alexander-e1off alexander-e1off requested a review from a team as a code owner September 3, 2024 08:28
@alexander-e1off alexander-e1off changed the title Augment brkr log [MQB] Add log with session/queue operations time Sep 3, 2024
Signed-off-by: Aleksandr Ivanov <aivanov71@bloomberg.net>
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 227 of commit a65b482 has completed with FAILURE

@678098 678098 changed the title [MQB] Add log with session/queue operations time Feat[MQB]: Add log with session/queue operations time Sep 3, 2024
? streamParamsCtrlMsg.choice().configureQueueStream().qId()
: streamParamsCtrlMsg.choice().configureStream().qId();

mwcu::MemOutStream logStream(&localAlloc);
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be beneficial to convert mwcu::MemOutStream to a field for this class, to avoid construction/deconstruction for any queue operation. It might also reduce the number of allocations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added class member d_logOpStream.

{
if (d_beginTimestamp) {
const bsls::Types::Int64 elapsed =
mwcsys::Time::highResolutionTimer() - d_beginTimestamp;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This initialization might be moved to BLOCK INFO, since it's used for logging only

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved under BALL_LOG_INFO_BLOCK

src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp Outdated Show resolved Hide resolved

if (begin) {
const bsls::Types::Int64 elapsed =
mwcsys::Time::highResolutionTimer() - begin;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be moved to BLOCK INFO

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved under BALL_LOG_INFO_BLOCK

Signed-off-by: Aleksandr Ivanov <aivanov71@bloomberg.net>
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 240 of commit 215a651 has completed with FAILURE

@@ -747,14 +747,32 @@ void ClientSession::onHandleConfiguredDispatched(
// PRECONDITIONS
BSLS_ASSERT_SAFE(dispatcher()->inDispatcherThread(this));

bdlma::LocalSequentialAllocator<2048> localAlloc(d_state.d_allocator_p);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be good to move this initialization back down, since there is a code path with early return where this allocator is not constructed (line 771).

if (isDisconnected()) {
// The client is disconnected or the channel is down
logOperationTime();
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 it was good to just pass the stream argument as before, even if we store it as a field now. Now the usage of logOperationTime is a bit obscure, it relies on a hidden dependency on d_logOpStream.

With argument passed, this dependency is shown in the interface.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am thinking if it's worth it to rename d_logOpStream to d_currentOpDescription to make it more clear

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added argument to logOperationTime, renamed to d_currentOpDescription.

{ // Save begin session timestamp
bslmt::LockGuard<bslmt::Mutex> guard(&d_mutex); // LOCK
d_timestampMap[channel.get()] =
mwcsys::Time::highResolutionTimer();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am concerned about these synchronizations between different threads on channel operations. I believe it's possible to store these timestamps directly in one of the mwcio::Channel implementations, so we don't need a mutex synchronization for them at all.

Let's add TODO for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree, but for this it's needed to change interface and implementations. So added TODO for now.

Signed-off-by: Aleksandr Ivanov <aivanov71@bloomberg.net>
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 241 of commit 0e558d8 has completed with FAILURE

@alexander-e1off alexander-e1off merged commit a6291d5 into bloomberg:main Sep 6, 2024
34 checks passed
@alexander-e1off alexander-e1off deleted the augment-brkr-log branch September 6, 2024 15:21
alexander-e1off added a commit to alexander-e1off/blazingmq that referenced this pull request Oct 24, 2024
alexander-e1off added a commit to alexander-e1off/blazingmq that referenced this pull request Oct 24, 2024
alexander-e1off added a commit to alexander-e1off/blazingmq that referenced this pull request Oct 24, 2024
if (queueStateIter != d_queueSessionManager.queues().end()) {
d_currentOpDescription
<< "Configure queue '"
<< queueStateIter->second.d_handle_p->queue()->uri() << "'";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This SEGFAULTs if d_handle_p is 0 (after dropAllQueueHandles)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants