Python devices use up to 130% of my processor. How is this possible?

I am currently doing some intensive load I / O tests using python. My whole program is to send HTTP requests as quickly as possible to the target server.

To manage this, I use up to 20 threads , as I am essentially related to I / O and remote server restrictions.

According to "top", CPython uses a peak of 130% CPU on my dual-core computer.

How is this possible? I thought GIL did it interfere? Or how does Linux โ€œcountโ€ the resources consumed by each application?

+2
source share
3 answers

100 percent in the upper part belong to one core. On a dual-core machine, you have up to 200 percent.

One single-threaded process can use only one core, so it is limited to 100 percent. Since your process has multiple threads, nothing prevents it from using both cores.

GIL only prevents pure-Python code from running at the same time. Many library calls (including most I / O materials) issue GILs, so there is no problem. Contrary to most FUDs on the Internet, GIL rarely reduces real-time performance, and if so, it is usually better to solve the problem than using streams.

+10
source

, C- GIL .

0

If you find this annoying, set your preferences (in particular, the preferences of your system monitor or equivalent tool) to enable Solaris Mode, which calculates CPU% as a percentage of the total processing power, rather than the proportion of one main processing power.

0
source

All Articles