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

[Refactor] Pass uniquely owned custom providers to the GlobalMetadataProvider #134

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

patnebe
Copy link
Collaborator

@patnebe patnebe commented Jan 15, 2025

Context

  • The additional thread-safety mechanisms/synchronisation layer around the registered custom providers seems redundant and could lead to additional overhead.
  • Since the collector uses a ThreadSafeGlobalMetadataProvider', the additional synchronization around each internal member of that class might not be needed.

Changes

  • Remove the Arc<Mutex<>> wrapper around the registered custom providers
  • Pass uniquely owned custom providers to the GlobalMetadataProvider

Test Plan

  • Existing CI checks.

@patnebe patnebe changed the title [Refactor] Make the globalmetadaprovider the single owner for each custom provider [Refactor] Pass uniquely owned custom providers to the GlobalMetadataProvider Jan 15, 2025
@patnebe patnebe requested a review from javierhonduco January 15, 2025 08:46
@patnebe patnebe marked this pull request as ready for review January 15, 2025 08:47
@patnebe
Copy link
Collaborator Author

patnebe commented Jan 15, 2025

cc @javierhonduco As per the notes in the description above. Do you have any concerns about relaxing the thread safety requirements for the custom providers?

@javierhonduco
Copy link
Owner

Thanks for the PR! Taking a look soon, looks good overall!

Copy link
Owner

@javierhonduco javierhonduco left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for the change. As you mention the top-level struct mutex should be enough here. Reading the code now, a small improvement we could make is to use a read-write lock for metadata. What do you think?

@javierhonduco javierhonduco merged commit f57f194 into javierhonduco:main Jan 15, 2025
4 checks passed
@patnebe patnebe deleted the refactor-custom-metadata branch January 15, 2025 16:21
@patnebe
Copy link
Collaborator Author

patnebe commented Jan 21, 2025

Looks good! Thanks for the change. As you mention the top-level struct mutex should be enough here. Reading the code now, a small improvement we could make is to use a read-write lock for metadata. What do you think?

Discussed this offline, but adding a note here for reference.

The interface for the GlobalMetadataProvider does not currently support/provide read-only vs write-only functions. All public methods on the class currently mutate the class's internal state. Hence wrapping the provider with a RwLock would probably not provide any additional benefit over a good old Mutex (which is the current implementation).

We ultimately decided that the current approach can be left as is, and revisited if there's a need to improve it further.

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.

2 participants