Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selection algorithm transcoding conflict patch #3181

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions server/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,23 @@ func (s *MinLSSelector) Select(ctx context.Context) *BroadcastSession {
return s.selectUnknownSession(ctx)
}

lowestLatencyScoreKnownSession := heap.Pop(s.knownSessions).(*BroadcastSession)
if lowestLatencyScoreKnownSession.LatencyScore <= s.minLS {
// known session has good enough latency score, use it
return lowestLatencyScoreKnownSession
minSess := sess.(*BroadcastSession)
if minSess.LatencyScore > s.minLS && len(s.unknownSessions) > 0 {
return s.selectUnknownSession(ctx)
}

// known session does not have good enough latency score, clear the heap and use unknown session
s.knownSessions = &sessHeap{}
return s.selectUnknownSession(ctx)
return heap.Pop(s.knownSessions).(*BroadcastSession)

// TODO: Fix AI selection logic, remove above code and uncomment transcoding logic below.
// lowestLatencyScoreKnownSession := heap.Pop(s.knownSessions).(*BroadcastSession)
// if lowestLatencyScoreKnownSession.LatencyScore <= s.minLS {
// // known session has good enough latency score, use it
// return lowestLatencyScoreKnownSession
// }

// // known session does not have good enough latency score, clear the heap and use unknown session
// s.knownSessions = &sessHeap{}
// return s.selectUnknownSession(ctx)
}

// Size returns the number of sessions stored by the selector
Expand Down
Loading