@@ -79,6 +79,7 @@ def get_tasks_from_scheduler(client: distributed.Client) -> Any:
79
79
80
80
This function is executed on the scheduler pod.
81
81
"""
82
+
82
83
def get_tasks_on_scheduler (dask_scheduler : distributed .Scheduler ) -> dict [str , Any ]:
83
84
tasks = {}
84
85
for task_id , task in dask_scheduler .tasks .items ():
@@ -177,6 +178,7 @@ def len(self) -> int:
177
178
with self ._lock :
178
179
return len (self .queue_dict )
179
180
181
+ @cachetools .cachedmethod (lambda self : cachetools .TTLCache (maxsize = 1024 , ttl = 60 ))
180
182
def reset (self ) -> None :
181
183
with self ._lock :
182
184
self .queue_dict = dict ()
@@ -235,8 +237,8 @@ def from_address(
235
237
rules_hash = rules_hash ,
236
238
)
237
239
with session_maker_write () as session :
238
- qos .reload_rules (session = session )
239
- db .reset_qos_rules (session , qos )
240
+ perf_logger ( qos .reload_rules ) (session = session )
241
+ perf_logger ( db .reset_qos_rules ) (session , qos )
240
242
self = cls (
241
243
client = client ,
242
244
session_maker_read = session_maker_read ,
@@ -263,7 +265,7 @@ def set_request_error_status(
263
265
264
266
If the error reason is "KilledWorker":
265
267
- if the worker has been killed by the Nanny for memory usage, it add the event for the user
266
- - if the worker is killed for unknown reasons, it re-queues the request
268
+ - if the worker is killed for unknown reasons, it re-queues the request
267
269
if the requeue limit is not reached. This is configurable with the environment variable
268
270
"""
269
271
error_message = "" .join (traceback .format_exception (exception ))
@@ -327,10 +329,10 @@ def sync_database(self, session: sa.orm.Session) -> None:
327
329
328
330
- If the task is in the futures list it does nothing.
329
331
- If the task is not in the futures list but it is in the scheduler:
330
- - If the task is in memory (it is successful but it has been lost by the broker),
332
+ - If the task is in memory (it is successful but it has been lost by the broker),
331
333
it is set to successful.
332
334
- If the task is in error, it is set to failed.
333
- - If the task is not in the dask scheduler, it is re-queued.
335
+ - If the task is not in the dask scheduler, it is re-queued.
334
336
This behaviour can be changed with an environment variable.
335
337
"""
336
338
# the retrieve API sets the status to "dismissed", here the broker deletes the request
@@ -444,15 +446,15 @@ def sync_qos_rules(self, session_write) -> None:
444
446
- the requests from the self.queue.
445
447
If a request is updated the relative self.queue entry is updated too
446
448
"""
447
- qos_rules = db .get_qos_rules (session = session_write )
449
+ qos_rules = perf_logger ( db .get_qos_rules ) (session = session_write )
448
450
if tasks_number := len (self .internal_scheduler .queue ):
449
451
logger .info ("performance" , tasks_number = tasks_number )
450
452
for task in list (self .internal_scheduler .queue )[
451
453
: int (os .getenv ("BROKER_MAX_INTERNAL_SCHEDULER_TASKS" , 500 ))
452
454
]:
453
455
# the internal scheduler is used to asynchronously add qos rules to database
454
456
# it returns a new qos rule if a new qos rule is added to database
455
- request , new_qos_rules = task ["function" ](
457
+ request , new_qos_rules = perf_logger ( task ["function" ]) (
456
458
session = session_write ,
457
459
request = self .queue .get (task ["kwargs" ].get ("request_uid" )),
458
460
rules_in_db = qos_rules ,
@@ -527,6 +529,7 @@ def on_future_done(self, future: distributed.Future) -> str:
527
529
future .release ()
528
530
return future .key
529
531
532
+ @perf_logger
530
533
def submit_requests (
531
534
self ,
532
535
session_write : sa .orm .Session ,
@@ -568,10 +571,7 @@ def submit_request(
568
571
request_uid = request .request_uid ,
569
572
user_uid = request .user_uid ,
570
573
hostname = os .getenv ("CDS_PROJECT_URL" ),
571
- ** request .adaptor_properties .config ,
572
574
),
573
- form = request .adaptor_properties .form ,
574
- request = request .request_body .get ("request" , {}),
575
575
resources = request .request_metadata .get ("resources" , {}),
576
576
metadata = request .request_metadata ,
577
577
)
0 commit comments