You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an exception occurs in ProcessPoolExecutor work item, all the exception frame local variables are not garbage collected (or are garbage collected too lately) because they are referenced by the exception's traceback.
Attached file is a test case. With unpatched python 3.9 (debian bullseye) it prints:
root@truenas[~/freenas/freenas]# python test.py
At iteration 0 memory usage is 226070528
At iteration 1 memory usage is 318763008
At iteration 2 memory usage is 318509056
At iteration 3 memory usage is 321662976
At iteration 4 memory usage is 321404928
At iteration 5 memory usage is 324292608
At iteration 6 memory usage is 324296704
At iteration 7 memory usage is 326922240
At iteration 8 memory usage is 326922240
At iteration 9 memory usage is 329543680
With the proposed patch there is no memory usage growth:
At iteration 0 memory usage is 226410496
At iteration 1 memory usage is 226451456
At iteration 2 memory usage is 226451456
At iteration 3 memory usage is 226443264
At iteration 4 memory usage is 226443264
At iteration 5 memory usage is 226435072
At iteration 6 memory usage is 226426880
At iteration 7 memory usage is 226426880
At iteration 8 memory usage is 226435072
At iteration 9 memory usage is 226426880
I wonder if this patch also needs to be applied to Lib/multiprocessing/pool.py as it appears to me that Lib/concurrent/futures/process.py and Lib/multiprocessing/pool.py are quite similar in this aspect: sending exceptions with (stringified) traceback across process boundary. What do you think? @themylogin
Activity
themylogin commentedon Feb 18, 2022
If an exception occurs in ProcessPoolExecutor work item, all the exception frame local variables are not garbage collected (or are garbage collected too lately) because they are referenced by the exception's traceback.
Attached file is a test case. With unpatched python 3.9 (debian bullseye) it prints:
root@truenas[~/freenas/freenas]# python test.py
At iteration 0 memory usage is 226070528
At iteration 1 memory usage is 318763008
At iteration 2 memory usage is 318509056
At iteration 3 memory usage is 321662976
At iteration 4 memory usage is 321404928
At iteration 5 memory usage is 324292608
At iteration 6 memory usage is 324296704
At iteration 7 memory usage is 326922240
At iteration 8 memory usage is 326922240
At iteration 9 memory usage is 329543680
With the proposed patch there is no memory usage growth:
At iteration 0 memory usage is 226410496
At iteration 1 memory usage is 226451456
At iteration 2 memory usage is 226451456
At iteration 3 memory usage is 226443264
At iteration 4 memory usage is 226443264
At iteration 5 memory usage is 226435072
At iteration 6 memory usage is 226426880
At iteration 7 memory usage is 226426880
At iteration 8 memory usage is 226435072
At iteration 9 memory usage is 226426880
clchiou commentedon Sep 25, 2022
I wonder if this patch also needs to be applied to Lib/multiprocessing/pool.py as it appears to me that Lib/concurrent/futures/process.py and Lib/multiprocessing/pool.py are quite similar in this aspect: sending exceptions with (stringified) traceback across process boundary. What do you think? @themylogin