Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9a7e5b1b
Unverified
Kaydet (Commit)
9a7e5b1b
authored
May 28, 2019
tarafından
Inada Naoki
Kaydeden (comit)
GitHub
May 28, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-35279: reduce default max_workers of ThreadPoolExecutor (GH-13618)
üst
293e9f86
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
5 deletions
+22
-5
concurrent.futures.rst
Doc/library/concurrent.futures.rst
+9
-0
thread.py
Lib/concurrent/futures/thread.py
+8
-3
test_concurrent_futures.py
Lib/test/test_concurrent_futures.py
+2
-2
2019-05-28-19-14-29.bpo-35279.PX7yl9.rst
...S.d/next/Library/2019-05-28-19-14-29.bpo-35279.PX7yl9.rst
+3
-0
No files found.
Doc/library/concurrent.futures.rst
Dosyayı görüntüle @
9a7e5b1b
...
...
@@ -159,6 +159,15 @@ And::
.. versionchanged:: 3.7
Added the *initializer* and *initargs* arguments.
.. versionchanged:: 3.8
Default value of *max_workers* is changed to ``min(32, os.cpu_count() + 4)``.
This default value preserves at least 5 workers for I/O bound tasks.
It utilizes at most 32 CPU cores for CPU bound tasks which release the GIL.
And it avoids using very large resources implicitly on many-core machines.
ThreadPoolExecutor now reuses idle worker threads before starting
*max_workers* worker threads too.
.. _threadpoolexecutor-example:
...
...
Lib/concurrent/futures/thread.py
Dosyayı görüntüle @
9a7e5b1b
...
...
@@ -129,9 +129,14 @@ class ThreadPoolExecutor(_base.Executor):
initargs: A tuple of arguments to pass to the initializer.
"""
if
max_workers
is
None
:
# Use this number because ThreadPoolExecutor is often
# used to overlap I/O instead of CPU work.
max_workers
=
(
os
.
cpu_count
()
or
1
)
*
5
# ThreadPoolExecutor is often used to:
# * CPU bound task which releases GIL
# * I/O bound task (which releases GIL, of course)
#
# We use cpu_count + 4 for both types of tasks.
# But we limit it to 32 to avoid consuming surprisingly large resource
# on many core machine.
max_workers
=
min
(
32
,
(
os
.
cpu_count
()
or
1
)
+
4
)
if
max_workers
<=
0
:
raise
ValueError
(
"max_workers must be greater than 0"
)
...
...
Lib/test/test_concurrent_futures.py
Dosyayı görüntüle @
9a7e5b1b
...
...
@@ -755,8 +755,8 @@ class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest, BaseTestCase):
def
test_default_workers
(
self
):
executor
=
self
.
executor_type
()
self
.
assertEqual
(
executor
.
_max_workers
,
(
os
.
cpu_count
()
or
1
)
*
5
)
expected
=
min
(
32
,
(
os
.
cpu_count
()
or
1
)
+
4
)
self
.
assertEqual
(
executor
.
_max_workers
,
expected
)
def
test_saturation
(
self
):
executor
=
self
.
executor_type
(
4
)
...
...
Misc/NEWS.d/next/Library/2019-05-28-19-14-29.bpo-35279.PX7yl9.rst
0 → 100644
Dosyayı görüntüle @
9a7e5b1b
Change default *max_workers* of ``ThreadPoolExecutor`` from ``cpu_count() *
5`` to ``min(32, cpu_count() + 4))``. Previous value was unreasonably
large on many cores machines.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment