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

[chore] processor/deltatocumulative: remove global mutex #37682

Merged
merged 4 commits into from
Mar 14, 2025

Conversation

sh0rez
Copy link
Member

@sh0rez sh0rez commented Feb 4, 2025

Description

Before, deltatocumulative acquired a sync.Mutex on each ConsumeMetrics invocation. This inherently does not scale well.

To fix, I ran microbenchmarks of different threadsafe hashmap approaches and value types (see internal/research/tracking).

This implements the first finding, switching to xsync.MapOf for stream tracking and wrapping the individual datapoints into mutexes, to allow for higher parallelism.

Link to tracking issue

none

Testing

Existing test continue to pass.

A new TestStaleness was added using experimental Go 1.24 testing/synctest, which for now can only be run manually:

$ GOEXPERIMENT=synctest gotip test .  

@sh0rez
Copy link
Member Author

sh0rez commented Feb 4, 2025

cc @ArthurSens

@sh0rez sh0rez force-pushed the lockfree branch 2 times, most recently from d9b2c75 to bc276be Compare February 5, 2025 09:42
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

I did a first pass today, focused only on the first benchmark 😬

Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Did another pass here. I wonder if we could relax usage of generics, it feels like it's getting out of hand.

Why do we need Limited, Count and Sized implementations if we're never using them alone? There's one single usage of those maps and we're chaining them all together. Wouldn't it be more readable if we have one single generic implementation of this map?

@sh0rez sh0rez force-pushed the lockfree branch 2 times, most recently from be191cc to 554eb31 Compare February 19, 2025 15:29
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Sorry for taking so long to review this PR. I'm struggling a bit to follow everything 😬

It would be nice to add code comments to the benchmark as well!

@sh0rez sh0rez changed the title processor/deltatocumulative: remove global mutex [chore] processor/deltatocumulative: remove global mutex Feb 20, 2025
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Let me remove the approval, apparently there was a mistake in the last commits that messed up the module...?

Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

.

@sh0rez sh0rez force-pushed the lockfree branch 2 times, most recently from abf6d30 to ba6f401 Compare February 25, 2025 09:02
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Mar 12, 2025
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Thanks

@ArthurSens ArthurSens removed the Stale label Mar 13, 2025
@ArthurSens ArthurSens added the ready to merge Code review completed; ready to merge by maintainers label Mar 13, 2025
@atoulme atoulme merged commit 803b19a into open-telemetry:main Mar 14, 2025
171 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/deltatocumulative ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants