Skip to content

Commit d933e82

Browse files
committed
flux-resource: fix performance issue generting queue output
Problem: In commit 4243895 a test for an empty resource set was added to the queue property of the ResourceSetExtra class to avoid generating a queue for an empty resource set. However, the test for empty uses self.rlist, which is an expensive call. Also, the test is done for each queue in the config, even though the contents of the resource set won't change. Use self.ranks instead of self.rlist to check for an empty resource set and move the call out of the loop so it is made only once. Fixes #5857
1 parent a6abe63 commit d933e82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cmd/flux-resource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ def propertiesx(self):
443443
def queue(self):
444444
queues = ""
445445
if self.flux_config and "queues" in self.flux_config:
446+
if not self.ranks:
447+
return ""
446448
properties = json.loads(self.get_properties())
447449
for key, value in self.flux_config["queues"].items():
448-
if not self.rlist:
449-
continue
450450
if "requires" not in value or set(value["requires"]).issubset(
451451
set(properties)
452452
):

0 commit comments

Comments
 (0)