Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
The following test program gains about 10M per second under top, on Python 3.11 only (confirmed for all development stages: 3.11.0a4, 3.11.0b1, 3.11.0rc1, 3.11.0) . 3.10 shows no memory growth.
fromthreadingimportThreadwhileTrue:t1=Thread()t1.start()
For direct results, here's the same program using theresource module that I just saw used over at#98467:
fromthreadingimportThreadimportresourceprint("Before",resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024,"MB")i=0whileTrue:i+=1t1=Thread()t1.start()ifi%10000==0:print(f"memory after{i} iterations:",resource.getrusage(resource.RUSAGE_SELF).ru_maxrss/1024,"MB", )
The above program under Py 3.11.0 prints:
$ .venv-3.11/bin/python test5.py Before 8.14453125 MBmemory after 10000 iterations: 11.6875 MBmemory after 20000 iterations: 15.30078125 MBmemory after 30000 iterations: 18.65234375 MBmemory after 40000 iterations: 22.26171875 MBmemory after 50000 iterations: 25.87109375 MBmemory after 60000 iterations: 29.22265625 MBmemory after 70000 iterations: 32.83203125 MBmemory after 80000 iterations: 36.44140625 MBmemory after 90000 iterations: 39.78125 MBmemory after 100000 iterations: 43.390625 MB...under Python 3.10 it prints:
$ .venv-3.10/bin/python test5.py Before 9.25 MBmemory after 10000 iterations: 9.46484375 MBmemory after 20000 iterations: 9.47265625 MBmemory after 30000 iterations: 9.47265625 MBmemory after 40000 iterations: 9.47265625 MBmemory after 50000 iterations: 9.47265625 MBmemory after 60000 iterations: 9.47265625 MBmemory after 70000 iterations: 9.47265625 MBmemory after 80000 iterations: 9.47265625 MBthe issue looks extremely similar to another one we just fixed in greenlet, over atpython-greenlet/greenlet#328, although this one is much more surprising. Issue#98467 might also be related.
Environment:
$ uname -aLinux photon3 5.17.14-200.fc35.x86_64 #1 SMP PREEMPT Thu Jun 9 14:02:42 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux$ python3Python 3.11.0 (main, Nov 5 2022, 23:27:22) [GCC 11.3.1 20220421 (Red Hat 11.3.1-3)] on linux