-
Notifications
You must be signed in to change notification settings - Fork 1.1k
perf: reduce calls to GetWorkspaceByAgentID in GetWorkspaceAgentByID #21046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
#21047) This PR piggy backs on the agent API cached workspace added in earlier PRs to provide a fast path for avoiding `GetWorkspaceByID` calls in `GetLatestWorkspaceBuildByWorkspaceID` via injection of the workspaces RBAC object into the context. We can do this from the `agentConnectionMonitor` easily since we already cache the workspace. --------- Signed-off-by: Callum Styan <callumstyan@gmail.com>
- Loading branch information
There are no files selected for viewing
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a fast path test here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not very easy to do with the amount of mocking we do in some of these tests, especially given that tests circumvent actually calls to the DB to retrieve the agent in the the function and test that are updated in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any opportunity to create a helper for this logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely! I'd just thought of that while implementing yet another PR for this same fastpath pattern, and added the helper function there.
I had planned to do all the cleanup to use the helper in existing places in a single PR after the existing PRs, easier for reviewers IMO, but I can refactor any one of the existing PRs to do the helper + reuse in there if you think that's easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I merged the change with the helper, and used tasks to have AI update the other call sites for context injection in the latest commit. LMK what you guys think @zedkipp @Emyrk , it essentially just makes the error handling more consistent, we really only reduced LOC by about 10?