Skip to content

fix: performance optimizations: batch chat ACL queries, lint cache key, app health fast path - #29663

Open
fuxicodex wants to merge 6 commits into
coder:mainfrom
fuxicodex:perf-optimizations
Open

fuxicodex wants to merge 6 commits into
coder:mainfrom
fuxicodex:perf-optimizations

Conversation

@fuxicodex

Copy link
Copy Markdown

Summary

Batch of small, targeted performance optimizations found during a codebase review:

  • fix(coderd): batch chat ACL group member counts — replaced N+1 loop calling GetGroupMembersCountByGroupID with the existing GetGroupMembersCountByGroupIDs batch query (1 DB round trip instead of N).
  • ci: narrow golangci-lint cache key to dependency/config/workflow files instead of **/*.go — a pure source change (e.g. a test edit) no longer invalidates the lint cache, and PRs only restore without saving, so upstream runs always started cold.
  • fix(dbauthz): fast path for UpdateWorkspaceAppHealthByID — authorize against the cached workspace RBAC object injected by the agent RPC, falling back to GetWorkspaceByWorkspaceAppID only when absent/stale (mirrors UpdateWorkspaceAgentMetadata).
  • fix(agentapi): inject cached workspace RBAC before app health updates so the dbauthz fast path can skip the repeated per-app workspace query.

Test plan

  • go build ./coderd/... passes with Go 1.26.5 (matches go.mod)
  • go test ./coderd/database/dbauthz/... -run "TestNew/UpdateWorkspaceAppHealthByID" passes
  • go test ./coderd/agentapi/... completes successfully

🤖 Generated with FuXi

fuxicodex and others added 5 commits September 21, 2026 18:22
chatACLGroups queried member counts per group in a loop, causing N+1 DB
round trips. Use the existing GetGroupMembersCountByGroupIDs batch query
and fold results into a map instead.

Co-Authored-By: FuXi <fuxicodex@gmail.com>
hashFiles('**/*.go') invalidated the lint cache on every Go source change
(test edits included), and PRs only restore without saving, so upstream
runs always started cold. Key only on dependency/config/workflow changes.

Co-Authored-By: FuXi <fuxicodex@gmail.com>
Exclude .fuxi/ (projects, settings, scheduled tasks) from version
control so agent-local state is never committed.

Co-Authored-By: FuXi <fuxicodex@gmail.com>
UpdateWorkspaceAppHealthByID fetched the workspace on every call to
authorize the update, even when the agent RPC had already injected the
cached workspace RBAC object into the context. Follow the same
fast-path pattern as UpdateWorkspaceAgentMetadata: authorize against the
cached object and only fall back to GetWorkspaceByWorkspaceAppID when it
is absent or stale.

Co-Authored-By: FuXi <fuxicodex@gmail.com>
BatchUpdateAppHealths contained a per-app update loop, and each
UpdateWorkspaceAppHealthByID call triggers an authorization fetch of the
workspace. The AppsAPI already holds the cached workspace fields used by
the agent connection; inject them into the context up front so the
dbauthz fast path can skip the repeated workspace query.

Co-Authored-By: FuXi <fuxicodex@gmail.com>
@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@fuxicodex

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

cdrci2 added a commit to coder/cla that referenced this pull request Sep 21, 2026
@fuxicodex

Copy link
Copy Markdown
Author

recheck

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant