trio icon indicating copy to clipboard operation
trio copied to clipboard

Best number of `total_tokens` on the default `CapacityLimiter`

Open Kludex opened this issue 3 years ago • 1 comments

Hi there 👋

Yesterday, I asked on trio's Gitter channel if there was a reason for the number of total_tokens on the default CapacityLimiter to be 40. @njsmith reply was:

image

And I guess it's a good number, as it's been there for five years. 😅 But... As he mentioned, it would be interesting to find an optimal number there.

The part of the code I'm talking about:

https://github.com/python-trio/trio/blob/f2e2dd225eeb42b0b01302cbb5c0ef60e36b5d99/trio/_threads.py#L30-L32

I'm creating this issue mainly to see if we can come up with some ideas to have this optimal number there.

Ideas? 😅

Gitter conversation This is just for reference.

Link to the Gitter conversation

image image image image

References:

Kludex avatar Jul 01 '22 05:07 Kludex

It all depends on /what/ you're using it for I suppose. Might be a good idea to sample code and see how many instances use the default and how many that don't.

For example, I've always provided a number. I didn't even know a default was available, which I guess it makes sense as the builtin Process/Thread pools do. My use cases generally involve web scraping so I tend to keep my capacity fairly low < 10 as to not overwhelm servers.

Sxderp avatar Jul 07 '22 13:07 Sxderp