Skip to content

[9.0] fix: cache the proxy strength (not changing that often...)#8154

Merged
chrisburr merged 1 commit intoDIRACGrid:integrationfrom
fstagni:90_cache_ProxyStrength
Apr 15, 2025
Merged

[9.0] fix: cache the proxy strength (not changing that often...)#8154
chrisburr merged 1 commit intoDIRACGrid:integrationfrom
fstagni:90_cache_ProxyStrength

Conversation

@fstagni
Copy link
Copy Markdown
Contributor

@fstagni fstagni commented Apr 14, 2025

Given that anyway 90%+ of the calls would be for the same proxy over and over

BEGINRELEASENOTES

*Framework
FIX: Caching the proxy strength to avoid a DB call

ENDRELEASENOTES

Comment thread src/DIRAC/FrameworkSystem/DB/ProxyDB.py Outdated

_cache_getProxyStrength = TTLCache(maxsize=1000, ttl=600)

@cached(_cache_getProxyStrength, lock=Lock())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not sure it is a good idea to have a lock there. Given that the result is deterministic, we don't really care if the cache is filled several times, do we ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure, but according to the documentation these classes are not thread-safe, so I'd leave the lock. At the same time I think to put (maxsize=100, ttl=3600).

Comment thread src/DIRAC/FrameworkSystem/DB/ProxyDB.py Outdated
Comment on lines +401 to +403
_cache_getProxyStrength = TTLCache(maxsize=1000, ttl=600)

@cached(_cache_getProxyStrength, lock=Lock())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think there is any point in having a longer TTL than 10 minutes. It's already an eternity compared to the frequency with which this is called.

Suggested change
_cache_getProxyStrength = TTLCache(maxsize=1000, ttl=600)
@cached(_cache_getProxyStrength, lock=Lock())
@cached(TTLCache(maxsize=1000, ttl=600), lock=Lock())

@fstagni fstagni force-pushed the 90_cache_ProxyStrength branch from f1aa19e to 11ae785 Compare April 15, 2025 09:24
@chrisburr chrisburr merged commit 286b9df into DIRACGrid:integration Apr 15, 2025
23 checks passed
@DIRACGridBot DIRACGridBot added the sweep:ignore Prevent sweeping from being ran for this PR label Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sweep:ignore Prevent sweeping from being ran for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants