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

Enable metrics and fix lock contention #1124

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Shubham8287
Copy link
Contributor

@Shubham8287 Shubham8287 commented Apr 19, 2024

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.

@Shubham8287 Shubham8287 force-pushed the shub/fix-lock-metric-contention branch from 7c56a1e to 3b418c1 Compare April 19, 2024 08:32
@Shubham8287 Shubham8287 added test-with-bots Recommend to test under higher CCU include-in-perf-test labels Apr 19, 2024
@Shubham8287 Shubham8287 force-pushed the shub/fix-lock-metric-contention branch from 3b418c1 to 407fe22 Compare April 19, 2024 08:43
@Shubham8287 Shubham8287 self-assigned this Apr 19, 2024
Comment on lines +268 to +270
tokio::task::spawn_blocking(|| {
drop(all_ctx);
});
Copy link
Contributor

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.

Copy link
Contributor Author

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}")
}
});
Copy link
Contributor

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.

@bfops bfops added release-any To be landed in any release window and removed include-in-perf-test labels Apr 22, 2024
@bfops bfops requested a review from jdetter May 2, 2024 17:58
@Shubham8287 Shubham8287 closed this May 2, 2024
@Shubham8287 Shubham8287 force-pushed the shub/fix-lock-metric-contention branch from 234bf72 to 7c52ef5 Compare May 2, 2024 18:23
@Shubham8287 Shubham8287 reopened this May 2, 2024
@Shubham8287 Shubham8287 force-pushed the shub/fix-lock-metric-contention branch from 8b94df0 to f5947d3 Compare May 28, 2024 17:16
Copy link

github-actions bot commented May 31, 2024

Bot test failed. Please check the workflow run for details.

Copy link

github-actions bot commented May 31, 2024

Bot test failed. Please check the workflow run for details.

@@ -177,6 +177,18 @@ impl From<&ReducerContext> for txdata::Inputs {
}
}

impl Clone for ExecutionContext {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@cloutiertyler cloutiertyler added release-0.10 and removed release-any To be landed in any release window labels Jun 3, 2024
@bfops bfops added release-any To be landed in any release window backward-compatible and removed release-any To be landed in any release window labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants