Skip to content

Commit 24ba67d

Browse files
committed
Avoid passing pointer to Request in completionNotification
1 parent d89098a commit 24ba67d

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

internal/scheduling/execution.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ func Execute(cont *container.Container, r *scheduledRequest, isWarm bool) error
4747
}
4848

4949
// notify scheduler
50-
completions <- &completionNotification{r: r, cont: cont, failed: true}
50+
completions <- &completionNotification{funcName: r.Fun.Name, offloaded: r.offloaded, cont: cont, failed: true}
5151
return fmt.Errorf("[%s] Execution failed on container %v: %v ", r, cont.ID, err)
5252
}
5353

5454
if !response.Success {
5555
// notify scheduler
56-
completions <- &completionNotification{r: r, cont: cont, failed: true}
56+
completions <- &completionNotification{funcName: r.Fun.Name, offloaded: r.offloaded, cont: cont, failed: true}
5757
return fmt.Errorf("[%s] Function execution failed %v", r, cont.ID)
5858
}
5959

@@ -66,7 +66,7 @@ func Execute(cont *container.Container, r *scheduledRequest, isWarm bool) error
6666
r.InitTime = initTime + invocationWait.Seconds()
6767

6868
// notify scheduler
69-
completions <- &completionNotification{r: r, cont: cont, failed: false}
69+
completions <- &completionNotification{funcName: r.Fun.Name, offloaded: r.offloaded, report: *r.ExecutionReport, cont: cont, failed: false}
7070

7171
return nil
7272
}

internal/scheduling/scheduler.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,23 @@ func Run(p Policy) {
5353
case r = <-requests: // receive request
5454
go p.OnArrival(r)
5555
case c = <-completions:
56-
node.HandleCompletion(c.cont, c.r.Fun)
57-
p.OnCompletion(c.r.Fun, c.r.ExecutionReport)
58-
59-
if metrics.Enabled && !c.failed && c.r.ExecutionReport != nil {
60-
metrics.AddCompletedInvocation(c.r.Fun.Name, !c.r.ExecutionReport.IsWarmStart)
61-
if !c.r.offloaded {
62-
metrics.AddFunctionDurationValue(c.r.Fun.Name, c.r.ExecutionReport.Duration)
63-
if !c.r.ExecutionReport.IsWarmStart {
64-
metrics.AddFunctionInitTimeValue(c.r.Fun.Name, c.r.ExecutionReport.InitTime)
56+
f, found := function.GetFunction(c.funcName)
57+
if !found {
58+
log.Printf("Function %s not found", c.funcName)
59+
continue
60+
}
61+
node.HandleCompletion(c.cont, f)
62+
p.OnCompletion(f, &c.report)
63+
64+
if metrics.Enabled && !c.failed {
65+
metrics.AddCompletedInvocation(c.funcName, !c.report.IsWarmStart)
66+
if !c.offloaded {
67+
metrics.AddFunctionDurationValue(c.funcName, c.report.Duration)
68+
if !c.report.IsWarmStart {
69+
metrics.AddFunctionInitTimeValue(c.funcName, c.report.InitTime)
6570
}
6671
}
67-
outputSize := len(c.r.ExecutionReport.Result)
72+
outputSize := len(c.report.Result)
6873
metrics.AddFunctionOutputSizeValue(r.Fun.Name, float64(outputSize))
6974
}
7075
}

internal/scheduling/types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ type scheduledRequest struct {
1414
}
1515

1616
type completionNotification struct {
17-
failed bool
18-
r *scheduledRequest
19-
cont *container.Container
17+
failed bool
18+
funcName string
19+
offloaded bool
20+
report function.ExecutionReport
21+
cont *container.Container
2022
}
2123

2224
// schedDecision wraps a action made by the scheduler.

0 commit comments

Comments
 (0)