Simple TCP proxy
Andrew MacIntyre
andymac at pcug.org.au
Thu Jul 28 20:13:36 EDT 2022
On 29/07/2022 8:08 am, Chris Angelico wrote:
> It takes a bit of time to start ten thousand threads, but after that,
> the system is completely idle again until I notify them all and they
> shut down.
>
> (Interestingly, it takes four times as long to start 20,000 threads,
> suggesting that something in thread spawning has O(n²) cost. Still,
> even that leaves the system completely idle once it's done spawning
> them.)
Another cost of threads can be memory allocated as thread stack space,
the default size of which varies by OS (see e.g.
https://ariadne.space/2021/06/25/understanding-thread-stack-sizes-and-how-alpine-is-different/).
threading.stack_size() can be used to check and perhaps adjust the
allocation size.
--
-------------------------------------------------------------------------
Andrew I MacIntyre "These thoughts are mine alone..."
E-mail: andymac at pcug.org.au (pref) | Snail: PO Box 370
andymac at bullseye.apana.org.au (alt) | Belconnen ACT 2616
Web: http://www.andymac.org/ | Australia
More information about the Python-list
mailing list