Skip to content

Commit d6156f0

Browse files
committed
Metric-based cold start probability estimation
1 parent 5038444 commit d6156f0

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

internal/workflow/remote_offloading_policy.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"github.com/serverledge-faas/serverledge/internal/node"
66
"log"
7+
"math"
78
"net/http"
89
"strconv"
910
"strings"
@@ -342,16 +343,18 @@ func prepareParameters(r *Request, p *Progress) *remotePolicyParams {
342343
}
343344

344345
// Init Time
345-
coldStart := true // TODO: assuming cold start
346-
if !coldStart {
347-
params.InitTime[tupleKey(string(tid), CLOUD)] = 0
346+
coldStartProb := retrievedMetrics.RemoteColdStartProbability[f.Name]
347+
if math.IsNaN(coldStartProb) || math.IsInf(coldStartProb, 1) {
348+
coldStartProb = 1.0
349+
} else if coldStartProb < 0.0 {
350+
log.Printf("Cold start probability is negative: %f", coldStartProb)
351+
coldStartProb = 0.0
352+
}
353+
t, found = retrievedMetrics.AvgRemoteInitTime[f.Name]
354+
if found {
355+
params.InitTime[tupleKey(string(tid), CLOUD)] = t * coldStartProb
348356
} else {
349-
t, found = retrievedMetrics.AvgRemoteInitTime[f.Name]
350-
if found {
351-
params.InitTime[tupleKey(string(tid), CLOUD)] = t
352-
} else {
353-
params.InitTime[tupleKey(string(tid), CLOUD)] = 0.01 // no data: just guessing
354-
}
357+
params.InitTime[tupleKey(string(tid), CLOUD)] = 0.01 * coldStartProb // no data about init time: just guessing
355358
}
356359
}
357360
} else {

0 commit comments

Comments
 (0)