Skip to content

Find a running client by type or by agent without looking at every client (CHOO-3667) - #1235

Closed
abeldantas wants to merge 1 commit into
faster-event-loopfrom
client-registry-index
Closed

abeldantas wants to merge 1 commit into
faster-event-loopfrom
client-registry-index

Conversation

@abeldantas

Copy link
Copy Markdown
Collaborator

Every process keeps an actor for every client. Finding a workspace's admin, which every room created asks for, and the actor of an agent another process registered a moment before, read all of them. While 10,000 agents were being created, these lookups took about 11% of a process's CPU in a profile.

In this PR we index the running clients by type and tenant, and by agent (ClientLifecycleService._track and _forget). A lookup by agent that the index cannot answer looks only at the agents' clients whose agent row has not been seen yet.

Stack (merge order)

  1. Run the server on uvloop, and stop scanning every actor to find the one sending (CHOO-3667) #1223
  2. This PR ← you are here

…ient (CHOO-3667)

Every process keeps an actor for every client. Finding a workspace's
admin (every room created asks) and the actor of an agent another process
had just registered (a lookup that misses) read every actor. While 10,000
agents were being created, these lookups took about 11% of a process's
CPU in a profile.

The running clients are now indexed by type and tenant, and by agent
(ClientLifecycleService._track and _forget). A lookup by agent that the
index cannot answer looks only at the agents' clients whose agent row
has not been seen yet.
@abeldantas

Copy link
Copy Markdown
Collaborator Author

Combined into #1307 with the other scaling PRs.

@abeldantas abeldantas closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant