Open
Description
Description
This issue tracks a possible future improvement to the way expired prebuilds are filtered in the system.
Currently, we use in-memory filtering to separate expired from running (non-expired) prebuilds when constructing the PresetSnapshot
:
coder/coderd/prebuilds/global_snapshot.go
Lines 95 to 113 in 7b273b0
This approach is simple and performs well at the current scale. However, if the number of running prebuilds increases significantly, it may become a performance concern.
Context
- Database query
GetRunningPrebuiltWorkspaces
returns all running workspaces (non-expired and expired workspaces). - A new slice
Expired
was added toPresetSnapshot
, populated via in-memory filtering. - We chose not to add a DB query yet to keep the implementation small and simple: feat: implement expiration policy logic for prebuilds #17996 (comment)
Potential Improvement:
- Introduce a dedicated database query to fetch expired workspaces.
- Update the current
GetRunningPrebuiltWorkspaces
database query to only return non-expired workspaces. - This would avoid loading all running prebuilds into memory and manually filtering them.
- Likely to be more efficient at larger scale.
While in-memory filtering is sufficient for now, introducing a DB query helps future-proof the system and ensures consistent performance in larger on-prem installations.
Action Items
- Monitor performance as prebuild usage increases.
- Revisit this issue if:
- Prebuild count grows significantly.
- Memory usage or latency becomes a concern in prebuild snapshot construction.