Skip to content

feat: make provMutex a RWMutex in the registry#15

Open
volmedo wants to merge 1 commit intomainfrom
vic/fix/registry-provider-rwmutex
Open

feat: make provMutex a RWMutex in the registry#15
volmedo wants to merge 1 commit intomainfrom
vic/fix/registry-provider-rwmutex

Conversation

@volmedo
Copy link
Member

@volmedo volmedo commented Jun 9, 2025

Context

The registry uses a mutex to control access to the providers map. It is a regular mutex and it is used for both read and write operations. Go has a RWMutex that can differentiate when locking is requested for reads or writes. Using it can reduce contention in the lock, as reads don't need to be exclusive with other reads.

This change should make the registry able to serve more requests, especially for find tasks where the vast majority of operations are reads.

I think this change is also useful for upstream, so I'll send a PR there too.

Proposed Changes

Replace provMutex with a RWMutex and check all it's usages to see which of them only need the read lock instead of the full lock.

Tests

Testing all possible interactions between the different operations is unfeasible. Testing in staging will be our best bet IMO.

@volmedo volmedo self-assigned this Jun 9, 2025
Base automatically changed from vic/feat/reload-registry to main June 10, 2025 08:29
@volmedo volmedo force-pushed the vic/fix/registry-provider-rwmutex branch from 37f0dde to daeec88 Compare June 10, 2025 08:39
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