Skip to content

perf(coderd): cheaper chatd org membership checks#24361

Merged
ethanndickson merged 2 commits intomainfrom
ethan/cheaper-org-check-on-chat-create
Apr 15, 2026
Merged

perf(coderd): cheaper chatd org membership checks#24361
ethanndickson merged 2 commits intomainfrom
ethan/cheaper-org-check-on-chat-create

Conversation

@ethanndickson
Copy link
Copy Markdown
Member

@ethanndickson ethanndickson commented Apr 15, 2026

This change reuses the authenticated subject's existing organization membership information during chat creation instead of issuing an OrganizationMembers query.

The current query is still correct, so this is not required for correctness. However, workspaceapps already answers the same question more cheaply from the request's RBAC subject. This extracts that logic into rbac.Subject.HasOrganizationMembership and reuses it in both places, removing an extra database lookup from chat creation without changing the authorization behavior.

I'm currently debugging a Coder agents scaletest regression where a run on April 2, 2026 with 4800 concurrent chat creations passed, while the same run on April 15, 2026 does not. We could stagger chat creation to reduce the burst, but I'd rather understand why this bottleneck appeared in the first place so we can keep making small hot-path improvements like this one instead of only smoothing over the symptom.

@ethanndickson ethanndickson marked this pull request as ready for review April 15, 2026 09:03
@ethanndickson ethanndickson requested a review from Emyrk as a code owner April 15, 2026 09:03
@ethanndickson ethanndickson requested a review from johnstcn April 15, 2026 09:10
Copy link
Copy Markdown
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice simplification 👍

Comment thread coderd/exp_chats.go Outdated
@ethanndickson ethanndickson changed the title perf(coderd): reuse cheaper org membership checks perf(coderd): cheaper chatd org membership checks Apr 15, 2026
@ethanndickson ethanndickson merged commit 227f20d into main Apr 15, 2026
25 of 26 checks passed
@ethanndickson ethanndickson deleted the ethan/cheaper-org-check-on-chat-create branch April 15, 2026 14:12
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants