[Python-Dev] GIL behaviour under Windows

Sturla Molden sturla at molden.no
Wed Oct 21 17:10:54 CEST 2009


Antoine Pitrou skrev:
>>> (*) http://svn.python.org/view/sandbox/trunk/ccbench/
>>>       
>> I´ve run it twice on my dual core machine.  It hangs every time, but not in the same place:
>> D:\pydev\python\trunk\PCbuild>python.exe \tmp\ccbench.py
>>     
>
> Ah, you should report a bug then. ccbench is pure Python (and not
> particularly evil Python), it shouldn't be able to crash the
> interpreter.
>
>   
It does not crash the interpreter, but it seems it can deadlock.

Here is what I get con a quadcore (Vista, Python 2.6.3).




D:\>ccbench.py
--- Throughput ---

Pi calculation (Python)

threads=1: 568 iterations/s.
threads=2: 253 ( 44 %)
threads=3: 274 ( 48 %)
threads=4: 283 ( 49 %)

regular expression (C)

threads=1: 510 iterations/s.
threads=2: 508 ( 99 %)
threads=3: 503 ( 98 %)
threads=4: 502 ( 98 %)

bz2 compression (C)

threads=1: 456 iterations/s.
threads=2: 892 ( 195 %)
threads=3: 1320 ( 289 %)
threads=4: 1743 ( 382 %)

--- Latency ---

Background CPU task: Pi calculation (Python)

CPU threads=0: 0 ms. (std dev: 0 ms.)
CPU threads=1: 0 ms. (std dev: 0 ms.)
CPU threads=2: 0 ms. (std dev: 0 ms.)
CPU threads=3: 0 ms. (std dev: 0 ms.)
CPU threads=4: 0 ms. (std dev: 0 ms.)

Background CPU task: regular expression (C)

CPU threads=0: 0 ms. (std dev: 0 ms.)
CPU threads=1: 37 ms. (std dev: 21 ms.)
CPU threads=2: 379 ms. (std dev: 175 ms.)
CPU threads=3: 625 ms. (std dev: 310 ms.)
CPU threads=4: 718 ms. (std dev: 381 ms.)

Background CPU task: bz2 compression (C)

CPU threads=0: 0 ms. (std dev: 0 ms.)
CPU threads=1: 0 ms. (std dev: 0 ms.)
CPU threads=2: 0 ms. (std dev: 0 ms.)
CPU threads=3: 0 ms. (std dev: 0 ms.)
CPU threads=4: 1 ms. (std dev: 3 ms.)




D:\>ccbench.py
--- Throughput ---

Pi calculation (Python)

threads=1: 554 iterations/s.
threads=2: 400 ( 72 %)
threads=3: 273 ( 49 %)
threads=4: 231 ( 41 %)

regular expression (C)

threads=1: 508 iterations/s.
threads=2: 509 ( 100 %)
threads=3: 509 ( 100 %)
threads=4: 509 ( 100 %)

bz2 compression (C)

threads=1: 456 iterations/s.
threads=2: 897 ( 196 %)
threads=3: 1316 ( 288 %)

DEADLOCK





D:\>ccbench.py
--- Throughput ---

Pi calculation (Python)

threads=1: 559 iterations/s.
threads=2: 397 ( 71 %)
threads=3: 274 ( 49 %)
threads=4: 238 ( 42 %)

regular expression (C)

threads=1: 507 iterations/s.
threads=2: 499 ( 98 %)
threads=3: 505 ( 99 %)
threads=4: 495 ( 97 %)

bz2 compression (C)

threads=1: 455 iterations/s.
threads=2: 896 ( 196 %)
threads=3: 1320 ( 290 %)
threads=4: 1736 ( 381 %)

--- Latency ---

Background CPU task: Pi calculation (Python)

CPU threads=0: 0 ms. (std dev: 0 ms.)
CPU threads=1: 0 ms. (std dev: 0 ms.)
CPU threads=2: 0 ms. (std dev: 0 ms.)
CPU threads=3: 0 ms. (std dev: 0 ms.)
CPU threads=4: 0 ms. (std dev: 0 ms.)

Background CPU task: regular expression (C)

CPU threads=0: 0 ms. (std dev: 0 ms.)
CPU threads=1: 34 ms. (std dev: 21 ms.)
CPU threads=2: 358 ms. (std dev: 174 ms.)
CPU threads=3: 619 ms. (std dev: 312 ms.)
CPU threads=4: 742 ms. (std dev: 382 ms.)

Background CPU task: bz2 compression (C)

CPU threads=0: 0 ms. (std dev: 0 ms.)
CPU threads=1: 0 ms. (std dev: 0 ms.)
CPU threads=2: 0 ms. (std dev: 0 ms.)
CPU threads=3: 0 ms. (std dev: 0 ms.)
CPU threads=4: 6 ms. (std dev: 13 ms.)











More information about the Python-Dev mailing list