Skip to content

Commit

Permalink
Revert changes in selection.go
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko committed Oct 2, 2024
1 parent c3e5b39 commit 5907466
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 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

0 comments on commit 5907466

Please sign in to comment.