Skip to content

Commit

Permalink
Merge pull request livepeer#1404 from livepeer/nv/roundtrip-latencyscore
Browse files Browse the repository at this point in the history
Server: use roundtrip latencyscore
  • Loading branch information
kyriediculous authored Feb 27, 2020
2 parents e97b69b + 69e9959 commit bff57f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/segment_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func SubmitSegment(sess *BroadcastSession, seg *stream.HLSSegment, nonce uint64)
return &ReceivedTranscodeResult{
TranscodeData: tdata,
Info: tr.Info,
LatencyScore: transcodeDur.Seconds() / seg.Duration,
LatencyScore: tookAllDur.Seconds() / seg.Duration,
}, nil
}

Expand Down
11 changes: 7 additions & 4 deletions server/segment_rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/url"
"strings"
"testing"
"time"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/golang/protobuf/proto"
Expand Down Expand Up @@ -1276,7 +1277,7 @@ func TestSubmitSegment_Success(t *testing.T) {
if runChecks != nil {
runChecks(r)
}

time.Sleep(20 * time.Millisecond)
w.WriteHeader(http.StatusOK)
w.Write(buf)
})
Expand All @@ -1295,16 +1296,18 @@ func TestSubmitSegment_Success(t *testing.T) {

assert := assert.New(t)

segData := pm.RandBytes(1024)

runChecks = func(r *http.Request) {
assert.Equal("video/MP2T", r.Header.Get("Content-Type"))

data, err := ioutil.ReadAll(r.Body)
require.Nil(err)

assert.Equal([]byte("dummy"), data)
assert.Equal(segData, data)
}

noNameSeg := &stream.HLSSegment{Data: []byte("dummy")}
noNameSeg := &stream.HLSSegment{Data: segData}
tdata, err := SubmitSegment(s, noNameSeg, 0)

assert.Nil(err)
Expand All @@ -1314,7 +1317,7 @@ func TestSubmitSegment_Success(t *testing.T) {
assert.Nil(tdata.Info)

// Check that latency score calculation is different for different segment durations
// The transcode duration calculated in SubmitSegment should be about the same across all calls
// The round trip duration calculated in SubmitSegment should be about the same across all calls
noNameSeg.Duration = 5.0
tdata, err = SubmitSegment(s, noNameSeg, 0)
assert.Nil(err)
Expand Down

0 comments on commit bff57f9

Please sign in to comment.