From a094d9959f636dcfcc3905e3799e7e88b32f84be Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Mon, 23 Sep 2024 10:39:28 +0200 Subject: [PATCH 1/2] fix(ai): apply hotfix for AI selection algorithm 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. --- server/selection.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/server/selection.go b/server/selection.go index f3a80a481..c37d15e96 100644 --- a/server/selection.go +++ b/server/selection.go @@ -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 From 2df9e3aeb71d94e570a330f251dad005de8cb897 Mon Sep 17 00:00:00 2001 From: Rick Staa Date: Mon, 23 Sep 2024 10:43:40 +0200 Subject: [PATCH 2/2] chore(ai): update AI selection logic comment This commit makes the AI selection logic comment more descriptive. --- server/selection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/selection.go b/server/selection.go index c37d15e96..f13b094b8 100644 --- a/server/selection.go +++ b/server/selection.go @@ -144,7 +144,7 @@ func (s *MinLSSelector) Select(ctx context.Context) *BroadcastSession { return heap.Pop(s.knownSessions).(*BroadcastSession) - // TODO: Fix selection logic, remove above code and uncomment below code. + // 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