New GitHub issue #118749 from Venkat2811:<br>

<hr>

<pre>
# Bug report

### Bug description:

Hello Team,

Thanks for the great work so far and recent nogil efforts.  I wanted to explore performance of asyncio with [CPU-GPU bound multi-threading ](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor) in nogil setup.  So, started with simple benchmark as seen below:

```python
import sys
from concurrent.futures import ThreadPoolExecutor
def fib(n):
    if n < 2: return 1
    return fib(n-1) + fib(n-2)

threads = 8
if len(sys.argv) > 1:
    threads = int(sys.argv[1])

with ThreadPoolExecutor(max_workers=threads) as executor:
    for _ in range(threads):
        executor.submit(lambda: print(fib(34)))
```
[Original Source](https://github.com/colesbury/nogil?tab=readme-ov-file#example)

**Results:**
- python 3.13.a06 with gil:
htop shows 2 running tasks, and only one core is utilized for 100%

```bash
$ time /usr/bin/python3.13 fib.py 
9227465
9227465
9227465
9227465
9227465
9227465
9227465
9227465
/usr/bin/python3.13 fib.py  6,46s user 0,04s system 100% cpu 6,447 total
```

- `libpython3.13-nogil amd64 3.13.0~a6-1+jammy2` [source](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa/+packages) nogil:
htop shows 9 running tasks, and 8 cores close to 100% utilization, but slower.
```bash
$ time /usr/bin/python3.13-nogil -X gil=0 fib.py
9227465
9227465
9227465
9227465
9227465
9227465
9227465
9227465
/usr/bin/python3.13-nogil -X gil=0 fib.py  168,81s user 0,06s system 788% cpu 21,410 total
```
My CPU: `AMD Ryzen 7 5800X 8-Core Processor`
OS: `Ubuntu 22.04.4 LTS`

So looks like there is overhead when using multiple cores.  Is this expected with this version ? Are results similar with Intel & M1 CPUs as well ? 

Results documented [here](https://github.com/colesbury/nogil?tab=readme-ov-file#example) in version `3.9.12` on Intel is better.


### CPython versions tested on:

3.13

### Operating systems tested on:

Linux
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/118749">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>