-
Notifications
You must be signed in to change notification settings - Fork 167
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
Fix incorrect processing of VerificationFreq parameter #2740
Conversation
@@ -397,7 +397,7 @@ func (bsm *BroadcastSessionsManager) shouldSkipVerification(sessions []*Broadcas | |||
if !includesSession(sessions, bsm.verifiedSession) { | |||
return false | |||
} | |||
return common.RandomUintUnder(bsm.VerificationFreq) == 0 | |||
return common.RandomUintUnder(bsm.VerificationFreq) != 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooof good catch!
IIUC this method generates a random integer x
s.t. 0 <= x < VerificationFreq
and there would be a 1 / VerificationFreq
probability for the random integer to be 0. Since this method is checking if verification should be skipped, if the check on this line is whether the integer is equal to 0 then this method would return true 1 / VerificationFreq
of the time which is the opposite of what we want i.e. this method should return true (VericationFreq - 1) / VerificationFreq)
of the time.
Codecov Report
@@ Coverage Diff @@
## master #2740 +/- ##
=============================================
Coverage 56.34825% 56.34825%
=============================================
Files 88 88
Lines 19147 19147
=============================================
Hits 10789 10789
Misses 7767 7767
Partials 591 591
Continue to review full report at Codecov.
|
* fix semantics of shouldSkipVerification * go fmt * Fix test to align with the meaning of verificationFreq parameter
About
VerificationFreq
parameter of the transcoding job controls how often fast verification is re-run on an already verified O session. Fast verification involves transcoding segment with 1 trusted and 2 untrusted Os, instead of using a single O. This PR fixes incorrect processing of this parameter. Valid values are 0 and positive integers. IfVerificationFreq = 0
, fast verification logic is fully disabled. IfVerificationFreq=N>0
, then, after initial verification run for a new O session, it will run again for a segment with a probability of1 / VerificationFreq
.Issue
The
shouldSkipVerification
function usedVerificationFreq
parameter in an inverted way.VerificationFreq=1
caused fast verification to run only once, as long as verified session is available, and higher values caused fast verification to run more and more often, with a value of e.g. 40 giving a 97.5% chance of running fast verification for each new segment of the stream.