python-trio / python-trio/trio

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

Open
#2,364 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance
Dominant language
Python
Stars
7.3k
Forks
431
Avg merge
2d 17h
Merged PRs (30d)
6

Description

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading trio/_threads.py around lines 30-32, the linked Gitter discussion, and the Gunicorn 2-4 * NUM_CORES reference. The issue does not define completion; it needs an agreed way to choose the default and an accompanying change or documented conclusion.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.