@@ -79,6 +79,9 @@ type Options struct {
79
79
ModifiedProcesses chan []* agentproc.Process
80
80
// ProcessManagementTick is used for testing process priority management.
81
81
ProcessManagementTick <- chan time.Time
82
+ // PrioritizedPIDs are processes that should have preferred CPU allocation
83
+ // and be de-prioritized for OOM Killer selection.
84
+ PrioritizedPIDs []int
82
85
}
83
86
84
87
type Client interface {
@@ -161,6 +164,7 @@ func New(options Options) Agent {
161
164
syscaller : options .Syscaller ,
162
165
modifiedProcs : options .ModifiedProcesses ,
163
166
processManagementTick : options .ProcessManagementTick ,
167
+ prioritizedPIDs : options .PrioritizedPIDs ,
164
168
165
169
prometheusRegistry : prometheusRegistry ,
166
170
metrics : newAgentMetrics (prometheusRegistry ),
@@ -221,6 +225,9 @@ type agent struct {
221
225
modifiedProcs chan []* agentproc.Process
222
226
// processManagementTick is used for testing process priority management.
223
227
processManagementTick <- chan time.Time
228
+ // prioritizedPIDs are processes that should have preferred CPU allocation
229
+ // and be de-prioritized for OOM Killer selection.
230
+ prioritizedPIDs []int
224
231
}
225
232
226
233
func (a * agent ) TailnetConn () * tailnet.Conn {
@@ -1278,8 +1285,6 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
1278
1285
}
1279
1286
}
1280
1287
1281
- var prioritizedProcs = []string {"coder" }
1282
-
1283
1288
func (a * agent ) manageProcessPriorityLoop (ctx context.Context ) {
1284
1289
if val := a .envVars [EnvProcPrioMgmt ]; val == "" || runtime .GOOS != "linux" {
1285
1290
a .logger .Debug (ctx , "process priority not enabled, agent will not manage process niceness/oom_score_adj " ,
@@ -1337,11 +1342,9 @@ func (a *agent) manageProcessPriority(ctx context.Context) ([]*agentproc.Process
1337
1342
slog .F ("pid" , proc .PID ),
1338
1343
)
1339
1344
1340
- // Trim off the path e.g. "./coder" -> "coder"
1341
- name := filepath .Base (proc .Name ())
1342
1345
// If the process is prioritized we should adjust
1343
1346
// it's oom_score_adj and avoid lowering its niceness.
1344
- if slices .Contains (prioritizedProcs , name ) {
1347
+ if slices .Contains (a . prioritizedPIDs , int ( proc . PID ) ) {
1345
1348
err = proc .SetOOMAdj (oomScoreAdj )
1346
1349
if err != nil {
1347
1350
logger .Warn (ctx , "unable to set proc oom_score_adj" ,
0 commit comments