summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-03-22 16:39:21 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitec7ea27e356dc159b37cc2a09b6f14841e796ab2 (patch)
tree75338cdc03d3a969ec707b8baff3aff16664d43e /lib/puppet
parent68ce086e6b57f67998c52073109e0cca0aee7002 (diff)
downloadpuppet-ec7ea27e356dc159b37cc2a09b6f14841e796ab2.tar.gz
puppet-ec7ea27e356dc159b37cc2a09b6f14841e796ab2.tar.xz
puppet-ec7ea27e356dc159b37cc2a09b6f14841e796ab2.zip
Refactoring event queueing for performance
This does some normalization so we're not doing duplicate queries for large event collections. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/transaction/event_manager.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb
index f74927b3c..24e577803 100644
--- a/lib/puppet/transaction/event_manager.rb
+++ b/lib/puppet/transaction/event_manager.rb
@@ -33,7 +33,17 @@ class Puppet::Transaction::EventManager
def queue_events(resource, events)
@events += events
- events.each do |event|
+ # Do some basic normalization so we're not doing so many
+ # graph queries for large sets of events.
+ events.inject({}) do |collection, event|
+ collection[event.name] ||= []
+ collection[event.name] << event
+ collection
+ end.collect do |name, list|
+ # It doesn't matter which event we use - they all have the same source
+ # and name here.
+ event = list[0]
+
# Collect the targets of any subscriptions to those events. We pass
# the parent resource in so it will override the source in the events,
# since eval_generated children can't have direct relationships.
@@ -41,7 +51,9 @@ class Puppet::Transaction::EventManager
next unless method = edge.callback
next unless edge.target.respond_to?(method)
- queue_event_for_resource(resource, edge.target, method, event)
+ list.each do |e|
+ queue_event_for_resource(resource, edge.target, method, e)
+ end
end
if resource.self_refresh? and ! resource.deleting?