-
Notifications
You must be signed in to change notification settings - Fork 101
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
Enable metrics and fix lock contention #1124
base: master
Are you sure you want to change the base?
Conversation
7c56a1e
to
3b418c1
Compare
3b418c1
to
407fe22
Compare
tokio::task::spawn_blocking(|| { | ||
drop(all_ctx); | ||
}); |
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.
While this is being done, we're holding a lock on the subscriptions manager. If you return this instead then you can drop the subscriptions lock and do the metrics work after.
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.
I thought about this, but as we are already not awaiting, it will at max save few microseconds but no strong opinions, can do it.
@@ -261,6 +265,9 @@ impl SubscriptionManager { | |||
tracing::warn!(%client.id, "failed to send update message to client: {e}") | |||
} | |||
}); |
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.
Not sure how much time we're spending in this eval.into_iter.for_each(...)
, but we could move this earlier by having the hash map that is iterated on be keyed over the client instead (and making its hash function use only the addr and identity). Then you could move that work to after the subscription lock has been dropped. In any case, this would be for a different PR.
234bf72
to
7c52ef5
Compare
8b94df0
to
f5947d3
Compare
Bot test failed. Please check the workflow run for details. |
Bot test failed. Please check the workflow run for details. |
@@ -177,6 +177,18 @@ impl From<&ReducerContext> for txdata::Inputs { | |||
} | |||
} | |||
|
|||
impl Clone for ExecutionContext { |
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.
A comment for why we need a custom Clone
?
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.
Sure I 'll add,
FYI, it's there so that ctx
can be shared across threads without using lock on metrics fields, which might be modified.
Description of Changes
Made
ctx
to not be shared between threads in subscription as that leads to lock contention.API and ABI breaking changes
No
Expected complexity level and risk
2, can affect perfoamance heavily.