Commit 73627a0
Callum Styan
perf(coderd): reduce GetWorkspaceBuildByJobID calls in ExtractWorkspaceAgentParam
The ExtractWorkspaceAgentParam middleware was making 3 calls to
GetWorkspaceBuildByJobID per request:
1. GetWorkspaceResourceByID → GetProvisionerJobByID cascade
2. Explicit GetProvisionerJobByID call
3. Explicit GetWorkspaceBuildByJobID call
This optimization:
- Adds GetWorkspaceResourceWithJobByIDNoAuth that fetches resource+job
in a single query while still performing proper authorization
- Updates ExtractWorkspaceAgentParam middleware to use it
- Reduces GetWorkspaceBuildByJobID calls from 3 to 1
This affects all endpoints using this middleware, including:
- GET /workspaceagents/{agent}/listening-ports (the primary target)
- GET /workspaceagents/{agent}/
- GET /workspaceagents/{agent}/logs
- And other agent-scoped endpoints1 parent 915b2b0 commit 73627a0
File tree
2 files changed
+29
-12
lines changed- coderd
- database/dbauthz
- httpmw
2 files changed
+29
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3942 | 3942 | | |
3943 | 3943 | | |
3944 | 3944 | | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
| 3963 | + | |
| 3964 | + | |
| 3965 | + | |
3945 | 3966 | | |
3946 | 3967 | | |
3947 | 3968 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| |||
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 64 | + | |
71 | 65 | | |
72 | 66 | | |
73 | 67 | | |
74 | 68 | | |
75 | 69 | | |
76 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
| |||
87 | 83 | | |
88 | 84 | | |
89 | 85 | | |
90 | | - | |
| 86 | + | |
91 | 87 | | |
92 | 88 | | |
93 | 89 | | |
| |||
0 commit comments