alter defaults for workers and threads to allow more parallel tasks #446

This commit is contained in:
jonaswinkler
2021-01-26 22:10:43 +01:00
parent f451b69ef3
commit f36115ee37
3 changed files with 13 additions and 12 deletions

View File

@@ -20,7 +20,7 @@ class TestSettings(TestCase):
self.assertEqual(default_threads, 1)
def test_workers_threads(self):
for i in range(2, 64):
for i in range(1, 64):
with mock.patch("paperless.settings.multiprocessing.cpu_count") as cpu_count:
cpu_count.return_value = i
@@ -31,4 +31,4 @@ class TestSettings(TestCase):
self.assertTrue(default_workers >= 1)
self.assertTrue(default_threads >= 1)
self.assertTrue(default_workers * default_threads < i, f"{i}")
self.assertTrue(default_workers * default_threads <= i, f"{i}")

View File

@@ -354,8 +354,10 @@ LOGGING = {
def default_task_workers():
# always leave one core open
available_cores = max(multiprocessing.cpu_count() - 1, 1)
available_cores = max(multiprocessing.cpu_count(), 1)
try:
if available_cores < 4:
return available_cores
return max(
math.floor(math.sqrt(available_cores)),
1
@@ -376,7 +378,7 @@ Q_CLUSTER = {
def default_threads_per_worker(task_workers):
# always leave one core open
available_cores = max(multiprocessing.cpu_count() - 1, 1)
available_cores = max(multiprocessing.cpu_count(), 1)
try:
return max(
math.floor(available_cores / task_workers),