Why performance is improved when thread count is increased than the hardware-possible thread count?Technically, why are processes in Erlang more efficient than OS threads?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Thread count increases a lot, even when deleting the threads“Large data” work flows using pandaspthread offer no performance increase when using virtual coresPerformance of Concurrent Program Degrading with Increase in Threads?Performance Decrease by Increasing Threads Number More Than 4 in 24 Core CPUWhy does the fitting time of a gam increases with the number of threads used?Python multiprocessing: dealing with 2000 processesPython multiprocessing Pool API doesn't work efficiently when process count and worker count increased
Bash function: Execute $@ command with each argument in sequence executed separately
How to write a nice frame challenge?
What does this Swiss black on yellow rectangular traffic sign with a symbol looking like a dart mean?
What are the mechanical differences between Adapt and Monstrosity?
I'm yearning in grey
Are there any individual aliens that have gained superpowers in the Marvel universe?
Having some issue with notation in a Hilbert space
How to ask if I can mow my neighbor's lawn
Right indicator flash-frequency has increased and rear-right bulb is out
Do details of my undergraduate title matter?
I just entered the USA without passport control at Atlanta airport
How could I create a situation in which a PC has to make a saving throw or be forced to pet a dog?
Is a sequel allowed to start before the end of the first book?
What is "dot" sign in •NO?
What is the context for Napoleon's quote "[the Austrians] did not know the value of five minutes"?
How do I become a better writer when I hate reading?
How can I maintain game balance while allowing my player to craft genuinely useful items?
Probability Dilemma
Simplify, equivalent for (p ∨ ¬q) ∧ (¬p ∨ ¬q)
Should I email my professor to clear up a (possibly very irrelevant) awkward misunderstanding?
Do my partner and son need an SSN to be dependents on my taxes?
You may find me... puzzling
Digital signature that is only verifiable by one specific person
How can I ping multiple IP addresses at the same time?
Why performance is improved when thread count is increased than the hardware-possible thread count?
Technically, why are processes in Erlang more efficient than OS threads?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Thread count increases a lot, even when deleting the threads“Large data” work flows using pandaspthread offer no performance increase when using virtual coresPerformance of Concurrent Program Degrading with Increase in Threads?Performance Decrease by Increasing Threads Number More Than 4 in 24 Core CPUWhy does the fitting time of a gam increases with the number of threads used?Python multiprocessing: dealing with 2000 processesPython multiprocessing Pool API doesn't work efficiently when process count and worker count increased
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
In my PC, I have 16 logical cores(multiprocessing.cpu_count()=16). I have an application which has around 2000 independent processes. I used multi-threading with different thread counts and the results are as follows.
Threads | Total Time(s)
8 | 4225 (~ 70 min)
16 | 2733 (~ 46 min)
32 | 2156 (~ 35 min)
64 | 2123 (~ 35 min)
Theoretically, I should get the best results when thread count is 16. And I should get the same results even if the thread count is increased above 16. But I'm getting the best results when the thread count is increased to 32. And the results looks to be unchanged above that count. What is the reason for that?
python python-3.x multithreading
add a comment |
In my PC, I have 16 logical cores(multiprocessing.cpu_count()=16). I have an application which has around 2000 independent processes. I used multi-threading with different thread counts and the results are as follows.
Threads | Total Time(s)
8 | 4225 (~ 70 min)
16 | 2733 (~ 46 min)
32 | 2156 (~ 35 min)
64 | 2123 (~ 35 min)
Theoretically, I should get the best results when thread count is 16. And I should get the same results even if the thread count is increased above 16. But I'm getting the best results when the thread count is increased to 32. And the results looks to be unchanged above that count. What is the reason for that?
python python-3.x multithreading
2
Not everything is CPU bound, i.e. your threads do not utilise your cores 100% all the time. By running multiple threads per core you are making use of that idle time.
– Selcuk
Mar 25 at 4:48
add a comment |
In my PC, I have 16 logical cores(multiprocessing.cpu_count()=16). I have an application which has around 2000 independent processes. I used multi-threading with different thread counts and the results are as follows.
Threads | Total Time(s)
8 | 4225 (~ 70 min)
16 | 2733 (~ 46 min)
32 | 2156 (~ 35 min)
64 | 2123 (~ 35 min)
Theoretically, I should get the best results when thread count is 16. And I should get the same results even if the thread count is increased above 16. But I'm getting the best results when the thread count is increased to 32. And the results looks to be unchanged above that count. What is the reason for that?
python python-3.x multithreading
In my PC, I have 16 logical cores(multiprocessing.cpu_count()=16). I have an application which has around 2000 independent processes. I used multi-threading with different thread counts and the results are as follows.
Threads | Total Time(s)
8 | 4225 (~ 70 min)
16 | 2733 (~ 46 min)
32 | 2156 (~ 35 min)
64 | 2123 (~ 35 min)
Theoretically, I should get the best results when thread count is 16. And I should get the same results even if the thread count is increased above 16. But I'm getting the best results when the thread count is increased to 32. And the results looks to be unchanged above that count. What is the reason for that?
python python-3.x multithreading
python python-3.x multithreading
asked Mar 25 at 4:42
Pradeep SanjeewaPradeep Sanjeewa
217
217
2
Not everything is CPU bound, i.e. your threads do not utilise your cores 100% all the time. By running multiple threads per core you are making use of that idle time.
– Selcuk
Mar 25 at 4:48
add a comment |
2
Not everything is CPU bound, i.e. your threads do not utilise your cores 100% all the time. By running multiple threads per core you are making use of that idle time.
– Selcuk
Mar 25 at 4:48
2
2
Not everything is CPU bound, i.e. your threads do not utilise your cores 100% all the time. By running multiple threads per core you are making use of that idle time.
– Selcuk
Mar 25 at 4:48
Not everything is CPU bound, i.e. your threads do not utilise your cores 100% all the time. By running multiple threads per core you are making use of that idle time.
– Selcuk
Mar 25 at 4:48
add a comment |
1 Answer
1
active
oldest
votes
Strictly speaking, Python cannot run more than one thread concurrently (because of GIL), so any threads that run Python code at 100% CPU usage (e.g. pure calculation) will always degrade in performance with more threads.
Getting any performance increases from threads means you have some I/O in your code that is being waited on, which makes your thread's CPU utilisation fall under 100%. Increasing the number of threads allows the CPU to fill up those gaps.
Your first paragraph is only partly true. Especially with I/O the GIL can and will be released.
– Klaus D.
Mar 25 at 4:54
@KlausD. I intended "any threads that run Python code at 100% CPU usage (e.g. pure calculation)" to cover it. Apparently I failed. What I wanted to say is, IO makes threads wait, so they are not "running" in that sense. You are welcome to reformulate the sentence if it will be more understandable.
– Amadan
Mar 25 at 4:55
@Amadan, processes I'm running in my code are independent. So, I don't have any code which is waiting for any I/O.
– Pradeep Sanjeewa
Mar 25 at 5:26
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331369%2fwhy-performance-is-improved-when-thread-count-is-increased-than-the-hardware-pos%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Strictly speaking, Python cannot run more than one thread concurrently (because of GIL), so any threads that run Python code at 100% CPU usage (e.g. pure calculation) will always degrade in performance with more threads.
Getting any performance increases from threads means you have some I/O in your code that is being waited on, which makes your thread's CPU utilisation fall under 100%. Increasing the number of threads allows the CPU to fill up those gaps.
Your first paragraph is only partly true. Especially with I/O the GIL can and will be released.
– Klaus D.
Mar 25 at 4:54
@KlausD. I intended "any threads that run Python code at 100% CPU usage (e.g. pure calculation)" to cover it. Apparently I failed. What I wanted to say is, IO makes threads wait, so they are not "running" in that sense. You are welcome to reformulate the sentence if it will be more understandable.
– Amadan
Mar 25 at 4:55
@Amadan, processes I'm running in my code are independent. So, I don't have any code which is waiting for any I/O.
– Pradeep Sanjeewa
Mar 25 at 5:26
add a comment |
Strictly speaking, Python cannot run more than one thread concurrently (because of GIL), so any threads that run Python code at 100% CPU usage (e.g. pure calculation) will always degrade in performance with more threads.
Getting any performance increases from threads means you have some I/O in your code that is being waited on, which makes your thread's CPU utilisation fall under 100%. Increasing the number of threads allows the CPU to fill up those gaps.
Your first paragraph is only partly true. Especially with I/O the GIL can and will be released.
– Klaus D.
Mar 25 at 4:54
@KlausD. I intended "any threads that run Python code at 100% CPU usage (e.g. pure calculation)" to cover it. Apparently I failed. What I wanted to say is, IO makes threads wait, so they are not "running" in that sense. You are welcome to reformulate the sentence if it will be more understandable.
– Amadan
Mar 25 at 4:55
@Amadan, processes I'm running in my code are independent. So, I don't have any code which is waiting for any I/O.
– Pradeep Sanjeewa
Mar 25 at 5:26
add a comment |
Strictly speaking, Python cannot run more than one thread concurrently (because of GIL), so any threads that run Python code at 100% CPU usage (e.g. pure calculation) will always degrade in performance with more threads.
Getting any performance increases from threads means you have some I/O in your code that is being waited on, which makes your thread's CPU utilisation fall under 100%. Increasing the number of threads allows the CPU to fill up those gaps.
Strictly speaking, Python cannot run more than one thread concurrently (because of GIL), so any threads that run Python code at 100% CPU usage (e.g. pure calculation) will always degrade in performance with more threads.
Getting any performance increases from threads means you have some I/O in your code that is being waited on, which makes your thread's CPU utilisation fall under 100%. Increasing the number of threads allows the CPU to fill up those gaps.
answered Mar 25 at 4:48
AmadanAmadan
138k13152203
138k13152203
Your first paragraph is only partly true. Especially with I/O the GIL can and will be released.
– Klaus D.
Mar 25 at 4:54
@KlausD. I intended "any threads that run Python code at 100% CPU usage (e.g. pure calculation)" to cover it. Apparently I failed. What I wanted to say is, IO makes threads wait, so they are not "running" in that sense. You are welcome to reformulate the sentence if it will be more understandable.
– Amadan
Mar 25 at 4:55
@Amadan, processes I'm running in my code are independent. So, I don't have any code which is waiting for any I/O.
– Pradeep Sanjeewa
Mar 25 at 5:26
add a comment |
Your first paragraph is only partly true. Especially with I/O the GIL can and will be released.
– Klaus D.
Mar 25 at 4:54
@KlausD. I intended "any threads that run Python code at 100% CPU usage (e.g. pure calculation)" to cover it. Apparently I failed. What I wanted to say is, IO makes threads wait, so they are not "running" in that sense. You are welcome to reformulate the sentence if it will be more understandable.
– Amadan
Mar 25 at 4:55
@Amadan, processes I'm running in my code are independent. So, I don't have any code which is waiting for any I/O.
– Pradeep Sanjeewa
Mar 25 at 5:26
Your first paragraph is only partly true. Especially with I/O the GIL can and will be released.
– Klaus D.
Mar 25 at 4:54
Your first paragraph is only partly true. Especially with I/O the GIL can and will be released.
– Klaus D.
Mar 25 at 4:54
@KlausD. I intended "any threads that run Python code at 100% CPU usage (e.g. pure calculation)" to cover it. Apparently I failed. What I wanted to say is, IO makes threads wait, so they are not "running" in that sense. You are welcome to reformulate the sentence if it will be more understandable.
– Amadan
Mar 25 at 4:55
@KlausD. I intended "any threads that run Python code at 100% CPU usage (e.g. pure calculation)" to cover it. Apparently I failed. What I wanted to say is, IO makes threads wait, so they are not "running" in that sense. You are welcome to reformulate the sentence if it will be more understandable.
– Amadan
Mar 25 at 4:55
@Amadan, processes I'm running in my code are independent. So, I don't have any code which is waiting for any I/O.
– Pradeep Sanjeewa
Mar 25 at 5:26
@Amadan, processes I'm running in my code are independent. So, I don't have any code which is waiting for any I/O.
– Pradeep Sanjeewa
Mar 25 at 5:26
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331369%2fwhy-performance-is-improved-when-thread-count-is-increased-than-the-hardware-pos%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Not everything is CPU bound, i.e. your threads do not utilise your cores 100% all the time. By running multiple threads per core you are making use of that idle time.
– Selcuk
Mar 25 at 4:48