Skip to content

Commit

Permalink
fix(ai): apply hotfix for AI selection algorithm
Browse files Browse the repository at this point in the history
While merging the main branch into the AI branch, the fragile AI selection
algorithm broke due to changes in the transcoding selection logic, which
the AI algorithm relies on. This commit provides a temporary patch to
ensure the selection process continues to function while we work on
improving the AI selection algorithm.
  • Loading branch information
rickstaa committed Sep 23, 2024
1 parent 9c20ce8 commit a094d99
Showing 1 changed file with 15 additions and 7 deletions.
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 selection logic, remove above code and uncomment below code.
// 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

0 comments on commit a094d99

Please sign in to comment.