Merge "Make the default executor configurable"
This commit is contained in:
+17
-1
@@ -62,11 +62,27 @@ entry.
|
||||
help='Explicitly specify the temporary working directory.'),
|
||||
cfg.IntOpt(
|
||||
'default_green_pool_size',
|
||||
deprecated_for_removal=True,
|
||||
deprecated_since='32.0.0',
|
||||
deprecated_reason="""
|
||||
This option is only used if the service is running in Eventlet mode. When
|
||||
that mode is removed this config option will be removed too.
|
||||
""",
|
||||
default=1000,
|
||||
min=100,
|
||||
help='''
|
||||
The total number of coroutines that can be run via nova's default
|
||||
greenthread pool concurrently, defaults to 1000, min value is 100.
|
||||
greenthread pool concurrently, defaults to 1000, min value is 100. It is only
|
||||
used if the service is running in Eventlet mode.
|
||||
'''),
|
||||
cfg.IntOpt(
|
||||
'default_thread_pool_size',
|
||||
default=10,
|
||||
min=1,
|
||||
help='''
|
||||
The total number of threads that can be run via nova's default
|
||||
thread pool concurrently. It is only used if the service is running in
|
||||
native threading mode.
|
||||
'''),
|
||||
cfg.IntOpt(
|
||||
'cell_worker_thread_pool_size',
|
||||
|
||||
+1
-1
@@ -199,7 +199,7 @@ class TestCase(base.BaseTestCase):
|
||||
self._service_fixture_count = collections.defaultdict(int)
|
||||
|
||||
self.useFixture(nova_fixtures.OpenStackSDKFixture())
|
||||
self.useFixture(nova_fixtures.IsolatedGreenPoolFixture(self.id()))
|
||||
self.useFixture(nova_fixtures.IsolatedExecutorFixture(self.id()))
|
||||
|
||||
self.useFixture(log_fixture.get_logging_handle_error_fixture())
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -1185,11 +1185,11 @@ class IndirectionAPIFixture(fixtures.Fixture):
|
||||
self.addCleanup(self.cleanup)
|
||||
|
||||
|
||||
class IsolatedGreenPoolFixture(fixtures.Fixture):
|
||||
"""isolate each test to a dedicated greenpool.
|
||||
class IsolatedExecutorFixture(fixtures.Fixture):
|
||||
"""isolate each test to a dedicated executor.
|
||||
|
||||
Replace the default shared greenpool with a pre test greenpool
|
||||
and wait for all greenthreads to finish in test cleanup.
|
||||
Replace the default shared executor with a per test executor
|
||||
and wait for all threads to finish in test cleanup.
|
||||
"""
|
||||
|
||||
def __init__(self, test):
|
||||
|
||||
@@ -1500,10 +1500,21 @@ class DefaultExecutorTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(
|
||||
utils, 'concurrency_mode_threading', new=mock.Mock(return_value=False))
|
||||
def test_executor_type_eventlet(self):
|
||||
def test_executor_type_and_size_eventlet(self):
|
||||
self.flags(default_green_pool_size=113)
|
||||
executor = utils._get_default_executor()
|
||||
|
||||
self.assertEqual('GreenThreadPoolExecutor', type(executor).__name__)
|
||||
self.assertEqual(113, executor._max_workers)
|
||||
|
||||
@mock.patch.object(
|
||||
utils, 'concurrency_mode_threading', new=mock.Mock(return_value=True))
|
||||
def test_executor_type_and_size_threading(self):
|
||||
self.flags(default_thread_pool_size=13)
|
||||
executor = utils._get_default_executor()
|
||||
|
||||
self.assertEqual('ThreadPoolExecutor', type(executor).__name__)
|
||||
self.assertEqual(13, executor._max_workers)
|
||||
|
||||
def test_executor_destroy(self):
|
||||
executor = utils._get_default_executor()
|
||||
|
||||
+8
-3
@@ -111,9 +111,14 @@ def _get_default_executor():
|
||||
global DEFAULT_EXECUTOR
|
||||
|
||||
if not DEFAULT_EXECUTOR:
|
||||
DEFAULT_EXECUTOR = futurist.GreenThreadPoolExecutor(
|
||||
CONF.default_green_pool_size
|
||||
)
|
||||
if concurrency_mode_threading():
|
||||
DEFAULT_EXECUTOR = futurist.ThreadPoolExecutor(
|
||||
CONF.default_thread_pool_size
|
||||
)
|
||||
else:
|
||||
DEFAULT_EXECUTOR = futurist.GreenThreadPoolExecutor(
|
||||
CONF.default_green_pool_size
|
||||
)
|
||||
|
||||
pname = multiprocessing.current_process().name
|
||||
executor_name = f"{pname}.default"
|
||||
|
||||
Reference in New Issue
Block a user