Skip to content

Commit 9e4fa46

Browse files
committed
fix(wasi): correctly compute InitTime
1 parent 61f9f4e commit 9e4fa46

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

internal/container/container.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,43 +87,42 @@ func wasiExecute(contID ContainerID, req *executor.InvocationRequest) (*executor
8787
}
8888

8989
res := &executor.InvocationResult{Success: false}
90-
t0 := time.Now()
9190
if wr.wasiType == WASI_TYPE_MODULE {
9291
// Create a new Wasi Configuration
9392
wcc, err := wr.BuildStore(contID, wf.engine, req.Handler, string(paramsBytes))
9493
if err != nil {
95-
return nil, time.Now().Sub(t0), err
94+
return nil, 0, err
9695
}
9796
defer wcc.Close()
9897

9998
// Create an instance of the module
10099
instance, err := wr.linker.Instantiate(wcc.store, wr.module)
101100
if err != nil {
102-
return nil, time.Now().Sub(t0), fmt.Errorf("Failed to instantiate WASI module: %v", err)
101+
return nil, 0, fmt.Errorf("Failed to instantiate WASI module: %v", err)
103102
}
104103

105104
// Get the _start function (entrypoint of any wasm module)
106105
start := instance.GetFunc(wcc.store, "_start")
107106
if start == nil {
108-
return nil, time.Now().Sub(t0), fmt.Errorf("WASI Module does not have a _start function")
107+
return nil, 0, fmt.Errorf("WASI Module does not have a _start function")
109108
}
110109

111110
// Call the _start function
112111
if _, err := start.Call(wcc.store); err != nil &&
113112
!strings.Contains(err.Error(), "exit status 0") {
114-
return nil, time.Now().Sub(t0), fmt.Errorf("Failed to run WASI module: %v", err)
113+
return nil, 0, fmt.Errorf("Failed to run WASI module: %v", err)
115114
}
116115

117116
// Read stdout from the temp file
118117
stdout, err := io.ReadAll(wcc.stdout)
119118
if err != nil {
120-
return nil, time.Now().Sub(t0), fmt.Errorf("Failed to read stdout for WASI: %v", err)
119+
return nil, 0, fmt.Errorf("Failed to read stdout for WASI: %v", err)
121120
}
122121

123122
// Read stderr from the temp file
124123
stderr, err := io.ReadAll(wcc.stderr)
125124
if err != nil {
126-
return nil, time.Now().Sub(t0), fmt.Errorf("Failed to read stderr for WASI: %v", err)
125+
return nil, 0, fmt.Errorf("Failed to read stderr for WASI: %v", err)
127126
}
128127

129128
// Populate result
@@ -170,7 +169,7 @@ func wasiExecute(contID ContainerID, req *executor.InvocationRequest) (*executor
170169
}
171170
}
172171

173-
return res, time.Now().Sub(t0), nil
172+
return res, 0, nil
174173
}
175174

176175
// Execute interacts with the Executor running in the container to invoke the

0 commit comments

Comments
 (0)