-
Notifications
You must be signed in to change notification settings - Fork 176
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
[v8.0] Match all the things #7907
base: rel-v8r0
Are you sure you want to change the base?
Conversation
7819a7b
to
4ba5244
Compare
4ba5244
to
b10bed7
Compare
class Limiter: | ||
# static variables shared between all instances of this class | ||
csDictCache = DictCache() | ||
condCache = DictCache() | ||
newCache = TwoLevelCache(10, 300) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably worth replacing condCache
with newCache
but I don't have time for it.
data = result["Value"] | ||
data = {k[0][attName]: k[1] for k in data} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data = result["Value"] | |
data = {k[0][attName]: k[1] for k in data} | |
data = {k[0][attName]: k[1] for k in result["Value"]} |
return result | ||
# It is critical that ``future`` is waited for outside of the lock as | ||
# _work aquires the lock before filling the caches. This also means | ||
# we can gaurentee that the future has not yet been removed from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# we can gaurentee that the future has not yet been removed from the | |
# we can guarantee that the future has not yet been removed from the |
@@ -12,10 +21,109 @@ | |||
from DIRAC.WorkloadManagementSystem.Client import JobStatus | |||
|
|||
|
|||
class TwoLevelCache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not seem to me there's anything "specific" to this class. What if you move it to a generic utility module?
self.futures: dict[str, Future] = {} | ||
self.pool = ThreadPoolExecutor(max_workers=max_workers) | ||
|
||
def get(self, key: str, populate_func: Callable[[], Any]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get(self, key: str, populate_func: Callable[[], Any]): | |
def get(self, key: str, populate_func: Callable[[], Any]) -> dict: |
In LHCbDIRAC we found that the matcher was struggling when there are many jobs running at a single site. This was caused by the JobDB being slow to do
select Type, count(*) from Jobs where Site = %(site)s group by Type
. Every 10 seconds the cache would expire and every thread would try to query the DB again and hang for a long time.Looking at the culmative response time over a couple of hours (with a similar number of requests in both periods) the new version is 98.9% faster.
Before this change:
After this change:
BEGINRELEASENOTES
*WorkloadManagment
CHANGE: Better caching performance in the Matching Limiter
ENDRELEASENOTES