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;








1















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?










share|improve this question

















  • 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

















1















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?










share|improve this question

















  • 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













1












1








1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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












  • 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












1 Answer
1






active

oldest

votes


















2














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.






share|improve this answer























  • 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 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
);



);













draft saved

draft discarded


















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









2














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.






share|improve this answer























  • 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















2














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.






share|improve this answer























  • 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













2












2








2







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해