(b *testing.B, args *benchmarkRuntimeArgs)
| 281 | } |
| 282 | |
| 283 | func findAndMarkRuntimeMap(b *testing.B, args *benchmarkRuntimeArgs) { |
| 284 | rtMap := NewRuntimeManager(getFuncletNode(), &RuntimeManagerParameters{MaxRuntimeIdle: 10, MaxRunnerDefunct: 30}) |
| 285 | for i := 0; i < args.RuntimeCount; i++ { |
| 286 | rtParams := &NewRuntimeParameters{ |
| 287 | RuntimeID: "runtime" + strconv.Itoa(i), |
| 288 | ConcurrentMode: true, |
| 289 | StreamMode: false, |
| 290 | WaitRuntimeAliveTimeout: 3, |
| 291 | Resource: &api.Resource{}, |
| 292 | } |
| 293 | rt := rtMap.NewRuntime(rtParams) |
| 294 | |
| 295 | params := &startRunnerParams{} |
| 296 | rt.initRunner(params) |
| 297 | str := "commitID" + strconv.Itoa(i%args.FunctionCount) |
| 298 | input := &InvocationInput{ |
| 299 | Configuration: &api.FunctionConfiguration{ |
| 300 | CommitID: &str, |
| 301 | FunctionConfiguration: lambda.FunctionConfiguration{ |
| 302 | MemorySize: &minMemory, |
| 303 | }, |
| 304 | }, |
| 305 | WithStreamMode: false, |
| 306 | } |
| 307 | |
| 308 | rtMap.OccupyColdRuntime(input) |
| 309 | rt.Release() |
| 310 | } |
| 311 | |
| 312 | maxParallel := int(args.Concurrency) * args.RuntimeCount |
| 313 | p := maxParallel / runtime.GOMAXPROCS(0) |
| 314 | b.Log("Parallelism ", p*runtime.GOMAXPROCS(0)) |
| 315 | b.SetParallelism(p) |
| 316 | b.RunParallel(func(pb *testing.PB) { |
| 317 | for i := 0; pb.Next(); i++ { |
| 318 | commitID := "commitID" + strconv.Itoa(i%args.FunctionCount) |
| 319 | rt := rtMap.FindWarmRuntime(&InvocationInput{ |
| 320 | Configuration: &api.FunctionConfiguration{ |
| 321 | CommitID: &commitID, |
| 322 | PodConcurrentQuota: args.Concurrency, |
| 323 | }, |
| 324 | }) |
| 325 | if rt != nil { |
| 326 | rt.Release() |
| 327 | } else { |
| 328 | b.Error("empty runtime", i) |
| 329 | } |
| 330 | } |
| 331 | }) |
| 332 | } |
| 333 | |
| 334 | func BenchmarkFindAndMark_1Conc1Func10Rt(b *testing.B) { |
| 335 | findAndMarkRuntimeMap(b, &benchmarkRuntimeArgs{ |
no test coverage detected