From 4a3f454029e0ea095415088bf7a654e819c7f43a Mon Sep 17 00:00:00 2001 From: Lucas Nussbaum Date: Mon, 3 Apr 2017 14:24:22 +0200 Subject: [PATCH 1/2] Factor out the building of the job description The job description was built once for every resource. Instead, build it once per job, and then just add the built description to each resource. This is an optimization attempt for bug #7970. --- lib/oar/resource.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/oar/resource.rb b/lib/oar/resource.rb index d8ea254a..44c8e3d7 100644 --- a/lib/oar/resource.rb +++ b/lib/oar/resource.rb @@ -123,6 +123,11 @@ module OAR active_jobs_by_moldable_id.each do |moldable_id, h| current = h[:job].running? + # prepare job description now, since it will be added to each resource + # For Result hash table, do not include events + # (otherwise the Set does not work with nested hash) + jobh = h[:job].to_reservation(:without => :events) + h[:resources].each do |resource_id| resource = resources[resource_id] # The resource does not belong to a valid cluster. @@ -138,11 +143,7 @@ module OAR end # if h[:job].besteffort? end # if current - # For Result hash table, do not include events - # (otherwise the Set does not work with nested hash) - result[resource.network_address][:reservations].add( - h[:job].to_reservation(:without => :events) - ) + result[resource.network_address][:reservations].add(jobh) end # .each do |resource_id| end # .each do |moldable_id, h| -- GitLab From 50c12fb7e51ecd82f69d2c2fd61665cfd08a00be Mon Sep 17 00:00:00 2001 From: Lucas Nussbaum Date: Mon, 3 Apr 2017 14:25:30 +0200 Subject: [PATCH 2/2] Fix indentation --- lib/oar/resource.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oar/resource.rb b/lib/oar/resource.rb index 44c8e3d7..fcf14b73 100644 --- a/lib/oar/resource.rb +++ b/lib/oar/resource.rb @@ -133,7 +133,7 @@ module OAR # The resource does not belong to a valid cluster. next if resource.nil? - result[resource.network_address] ||= initial_status_for(resource) + result[resource.network_address] ||= initial_status_for(resource) # abasu : if job is current, increment corresponding counter(s) in hash table if current -- GitLab