- Notifications
You must be signed in to change notification settings - Fork1k
Commit014a2d5
authored
perf: don't call GetUserByID unnecessarily for Agents metrics loops (#19395)
At the moment, the loop which retrieves and updates the values of theagents metrics excessively calls `GetUserByID` (a DB query). First itretrieves a list of all workspaces, filtering out inactive agents (notentirely clear to me whether this is non-running workspaces, or justdead agents), and then iterates over those workspaces to get the rest ofthe relevant data for the metrics. The next call is `GetUserByID` for`workspace.OwnerID`. This is unnecessary because the `workspaces_visible` view we pull workspaces from has already been joined with the users table to get the username/name/etc.This should at least partiallyresolvecoder/internal#726 ---------Signed-off-by: Callum Styan <callumstyan@gmail.com>1 parent8aafbcb commit014a2d5
File tree
3 files changed
+14
-32
lines changed- coderd
- agentapi
- prometheusmetrics
- workspacestats
3 files changed
+14
-32
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
44 |
| - | |
45 |
| - | |
46 |
| - | |
47 |
| - | |
48 |
| - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
49 | 50 |
| |
50 | 51 |
| |
51 | 52 |
| |
| |||
138 | 139 |
| |
139 | 140 |
| |
140 | 141 |
| |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 | 142 |
| |
145 | 143 |
| |
146 | 144 |
| |
| |||
380 | 378 |
| |
381 | 379 |
| |
382 | 380 |
| |
383 |
| - | |
384 |
| - | |
385 |
| - | |
386 | 381 |
| |
387 | 382 |
| |
388 | 383 |
| |
| |||
498 | 493 |
| |
499 | 494 |
| |
500 | 495 |
| |
501 |
| - | |
502 |
| - | |
503 |
| - | |
504 | 496 |
| |
505 | 497 |
| |
506 | 498 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
328 | 328 |
| |
329 | 329 |
| |
330 | 330 |
| |
331 |
| - | |
332 |
| - | |
333 |
| - | |
334 |
| - | |
335 |
| - | |
336 |
| - | |
| 331 | + | |
337 | 332 |
| |
338 | 333 |
| |
339 | 334 |
| |
340 | 335 |
| |
341 |
| - | |
| 336 | + | |
342 | 337 |
| |
343 | 338 |
| |
344 | 339 |
| |
345 | 340 |
| |
346 | 341 |
| |
347 |
| - | |
| 342 | + | |
348 | 343 |
| |
349 | 344 |
| |
350 | 345 |
| |
351 | 346 |
| |
352 | 347 |
| |
353 |
| - | |
| 348 | + | |
354 | 349 |
| |
355 | 350 |
| |
356 | 351 |
| |
| |||
360 | 355 |
| |
361 | 356 |
| |
362 | 357 |
| |
363 |
| - | |
| 358 | + | |
364 | 359 |
| |
365 | 360 |
| |
366 | 361 |
| |
| |||
385 | 380 |
| |
386 | 381 |
| |
387 | 382 |
| |
388 |
| - | |
| 383 | + | |
389 | 384 |
| |
390 | 385 |
| |
391 | 386 |
| |
| |||
397 | 392 |
| |
398 | 393 |
| |
399 | 394 |
| |
400 |
| - | |
| 395 | + | |
401 | 396 |
| |
402 | 397 |
| |
403 | 398 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
129 |
| - | |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 | 129 |
| |
135 |
| - | |
| 130 | + | |
136 | 131 |
| |
137 | 132 |
| |
138 | 133 |
| |
|
0 commit comments
Comments
(0)