Skip to content

Commit

Permalink
update cpu check log (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 authored Jan 16, 2024
1 parent 764bd13 commit 1ae9288
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pkg/stats/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,24 +300,27 @@ func (m *Monitor) canAcceptRequestLocked(req *rpc.StartEgressRequest) bool {
available = total - used - (total * (1 - m.cpuCostConfig.MaxCpuUtilization))
}

logger.Debugw("cpu check",
"total", total,
"available", available,
"active_requests", m.requests,
)

var required float64
switch req.Request.(type) {
case *rpc.StartEgressRequest_RoomComposite:
accept = available >= m.cpuCostConfig.RoomCompositeCpuCost
required = m.cpuCostConfig.RoomCompositeCpuCost
case *rpc.StartEgressRequest_Web:
accept = available >= m.cpuCostConfig.WebCpuCost
required = m.cpuCostConfig.WebCpuCost
case *rpc.StartEgressRequest_Participant:
accept = available >= m.cpuCostConfig.ParticipantCpuCost
required = m.cpuCostConfig.ParticipantCpuCost
case *rpc.StartEgressRequest_TrackComposite:
accept = available >= m.cpuCostConfig.TrackCompositeCpuCost
required = m.cpuCostConfig.TrackCompositeCpuCost
case *rpc.StartEgressRequest_Track:
accept = available >= m.cpuCostConfig.TrackCpuCost
required = m.cpuCostConfig.TrackCpuCost
}
accept = available >= required

logger.Debugw("cpu check",
"available", available,
"required", required,
"activeRequests", m.requests,
"canAccept", accept,
)

return accept
}
Expand Down

0 comments on commit 1ae9288

Please sign in to comment.