From d62e6e2a7fc4642cb95ddbe81438bc3e37cffd9d Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 31 Jul 2018 13:05:07 -0700 Subject: [PATCH] ansible: serialize calls to ModuleDepService. Concurrent calls to ModuleDepService would cause significant wasted work, as potentially all pool threads run the same uncached module dep scan. Without: 3243581 function calls (3233009 primitive calls) in 4770.672 seconds ncalls tottime percall cumtime percall filename:lineno(function) 2523 0.011 0.000 39.849 0.016 services.py:409(scan) With: 2801561 function calls (2800042 primitive calls) in 5166.843 seconds ncalls tottime percall cumtime percall filename:lineno(function) 2506 0.009 0.000 1.967 0.001 services.py:411(scan) Ignore timing variance due to problems with the test job. --- ansible_mitogen/services.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ansible_mitogen/services.py b/ansible_mitogen/services.py index a7bb7db1..e95fc226 100644 --- a/ansible_mitogen/services.py +++ b/ansible_mitogen/services.py @@ -388,6 +388,8 @@ class ModuleDepService(mitogen.service.Service): Scan a new-style module and produce a cached mapping of module_utils names to their resolved filesystem paths. """ + invoker_class = mitogen.service.SerializedInvoker + def __init__(self, *args, **kwargs): super(ModuleDepService, self).__init__(*args, **kwargs) self._cache = {}