-
Notifications
You must be signed in to change notification settings - Fork 141
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
Performance[MQBSTAT]: lookup for per-appId metrics O(n) -> O(1) #389
Conversation
Signed-off-by: Evgeny Malygin <[email protected]>
Signed-off-by: Evgeny Malygin <[email protected]>
Signed-off-by: Evgeny Malygin <[email protected]>
2a9f237
to
98af0da
Compare
@@ -53,6 +53,8 @@ mqbc::ClusterDataIdentity clusterIdentity(const bslstl::StringRef& name, | |||
// Create client identity | |||
bmqp_ctrlmsg::ClientIdentity identity(allocator); | |||
if (!isRemote) { | |||
BSLS_ASSERT_SAFE(netCluster->selfNode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the line 65 below, netCluster->selfNode()
is dereferenced without checks, which might lead to segfault. This might be achieved by using mock domain/cluster objects.
@@ -156,6 +156,10 @@ void Cluster::_initializeNetcluster() | |||
: k_LEADER_NODE_ID + 1; | |||
dynamic_cast<mqbnet::MockCluster*>(d_netCluster_mp.get()) | |||
->_setSelfNodeId(selfNodeId); | |||
|
|||
if (d_isClusterMember) { | |||
BSLS_ASSERT_OPT(0 != d_netCluster_mp->selfNode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another early safety check for the same problem with dereferencing selfNode
with mocks.
@@ -231,7 +235,12 @@ Cluster::Cluster(bdlbb::BlobBufferFactory* bufferFactory, | |||
, d_processor() | |||
{ | |||
// PRECONDITIONS | |||
BSLS_ASSERT_OPT(isClusterMember || !isLeader); | |||
if (isClusterMember) { | |||
BSLS_ASSERT_OPT(!clusterNodeDefs.empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Early safety check. Providing an empty clusterNodeDefs
makes it certain that selfNode
will be nullptr.
BALL_LOGTHROTTLE_WARN(k_MAX_INSTANT_MESSAGES, k_NS_PER_MESSAGE) | ||
<< "[THROTTLED] No built sub contexts"; | ||
<< "[THROTTLED] No built sub contexts for domain: " | ||
<< d_statContext_mp->name() << ", appId: " << appId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New log line looks like
06AUG2024_02:21:59.442 10822:8281000960 WARN /blazingmq/src/groups/mqb/mqbstat/mqbstat_queuestats.cpp:602 MQBSTAT.QUEUESTATS [THROTTLED] No matching StatContext for domain: bmq://mock-domain/abc, appId: bar
Signed-off-by: Evgeny Malygin <[email protected]>
Do you have source to this statement? It is quite inconvenient to have to use two data structures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments
Signed-off-by: Evgeny Malygin <[email protected]>
7eb93fc
to
f13b4cb
Compare
@kaikulimu ManagedPtr docs
So ManagedPtr doesn't satisfy the CopyConstructible requirements https://en.cppreference.com/w/cpp/named_req/CopyConstructible On SunOS, trying to build a
The first message could be simplified: If you check the ManagedPtr interfaces, there are no constructors accepting other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…mberg#389) Signed-off-by: Evgeny Malygin <[email protected]>
…mberg#389) Signed-off-by: Evgeny Malygin <[email protected]>
…mberg#389) Signed-off-by: Evgeny Malygin <[email protected]>
Previously, we used a
bsl::list<ManagedPtr<mwcst::StatContext> >
for 2 roles:The problem is that the
list
assumes linear search, which might be too slow if we have a decent number of appIds.However, due to the interfaces of
ManagedPtr
(onSolaris
), we cannot just use a container which might reallocate its elements on resize. So instead we keep&update 2 collections together:bsl::list
to holdManagedPointer
s andbsl::unordered_map
for fast lookup to raw pointers to the neededStatContext
sFull list of changes:
mqbstat::QueueStatsDomain
: hold managed pointers inbsl::list<StatSubContextMp> d_subContextsHolder
, lookup to subcontexts withbsl::unordered_map<bsl::string, mwcst::StatContext*> d_subContextsLookup
mqbstat::QueueStatsDomain
: pass allocator in constructormqbstat::QueueStatsDomain
: improve logging when no subcontext foundmqbc::ClusterDataIdentity
: add safety check to prevent possiblenullptr
dereferencemqbmock::Cluster
: add safety checks to find cluster misconfiguration earlymqbstat_queuestats.t.cpp
: add UT to check per-appId subcontexts and metrics