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

Registry optimizations #674

Merged
merged 5 commits into from
Feb 11, 2025
Merged

Registry optimizations #674

merged 5 commits into from
Feb 11, 2025

Conversation

aabidsofi19
Copy link
Member

Description

Improve Entity Retrieval with Memoization and Thread-Safe Caching

PR Description:

This PR adds a GetEntitiesMemoized function ( memoized version of getEntities function with a thread-safe cache (RegistryEntityCache) ) . This improves performance by avoiding redundant entity lookups and ensures safe concurrent access when multiple goroutines interact with the cache.

Key Changes:

  • Implemented memoization: Avoids redundant calls to rm.GetEntities(f) by caching previously fetched results.
  • *RegistryEntityCache**: A dedicated struct for entity caching, now using sync.Map for thread safety.
  • thread safe cache access*: Added Get and Set methods to RegistryEntityCache for cleaner and safer interactions.

Why This Change?

  • Performance Boost: Eliminates unnecessary entity lookups ( when doing bulk lookups like in case of design hydration) , reducing database/API load.
  • Thread Safety: Prevents race conditions when accessing the cache concurrently.
  • Cleaner Abstraction: Encapsulates caching logic inside RegistryEntityCache, making GetEntitiesMemoized easier to maintain.

Signed commits

  • Yes, I signed my commits.

Signed-off-by: Aabid Sofi <mailtoaabid01@gmail.com>
Signed-off-by: Aabid Sofi <mailtoaabid01@gmail.com>
Signed-off-by: Aabid Sofi <mailtoaabid01@gmail.com>
Signed-off-by: Aabid Sofi <mailtoaabid01@gmail.com>
Signed-off-by: Aabid Sofi <mailtoaabid01@gmail.com>
@aabidsofi19 aabidsofi19 merged commit 81bd491 into master Feb 11, 2025
2 of 4 checks passed
@aabidsofi19 aabidsofi19 deleted the registry-optimizations branch February 11, 2025 16:50
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.

1 participant